@ethersproject/abstract-signer#Signer TypeScript Examples

The following examples show how to use @ethersproject/abstract-signer#Signer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: utils.ts    From sdk with ISC License 7 votes vote down vote up
export function staticCallPopulatedTransaction(
    populatedTxn: Resolveable<PopulatedTransaction>,
    signer:       Signer
): Promise<StaticCallResult> {
    return Promise.resolve(populatedTxn)
        .then(txn => {
            return signer.call(txn)
                .then(()  => StaticCallResult.Success)
                .catch((err) => StaticCallResult.Failure)
        })
}
Example #2
Source File: helperFunctions.ts    From aavegotchi-contracts with MIT License 6 votes vote down vote up
export async function getDiamondSigner(
  hre: HardhatRuntimeEnvironment,
  override?: string,
  useLedger?: boolean
) {
  //Instantiate the Signer
  let signer: Signer;
  const owner = await (
    (await hre.ethers.getContractAt(
      "OwnershipFacet",
      maticDiamondAddress
    )) as OwnershipFacet
  ).owner();
  const testing = ["hardhat", "localhost"].includes(hre.network.name);

  if (testing) {
    await hre.network.provider.request({
      method: "hardhat_impersonateAccount",
      params: [override ? override : owner],
    });
    return await hre.ethers.getSigner(override ? override : owner);
  } else if (hre.network.name === "matic") {
    return (await hre.ethers.getSigners())[0];
  } else {
    throw Error("Incorrect network selected");
  }
}
Example #3
Source File: signatures.ts    From balancer-v2-monorepo with GNU General Public License v3.0 6 votes vote down vote up
static signSwapAuthorization = (
    validator: Contract,
    user: Signer & TypedDataSigner,
    allowedSender: Account,
    allowedCalldata: string,
    deadline?: BigNumberish,
    nonce?: BigNumberish
  ): Promise<string> =>
    RelayerAuthorization.signAuthorizationFor(
      RelayerAction.Swap,
      validator,
      user,
      allowedSender,
      allowedCalldata,
      deadline,
      nonce
    );
Example #4
Source File: JsonRpcMulticallProvider.ts    From davatar-helpers with MIT License 6 votes vote down vote up
getSigner(addressOrIndex?: string | number): Signer {
    if (!hasSigner(this.parent)) {
      return logger.throwError('Parent provider does not support getSigner', Logger.errors.NOT_IMPLEMENTED, {
        parent: this.parent,
      });
    }

    return this.parent.getSigner(addressOrIndex);
  }
Example #5
Source File: updateWearableSet.ts    From aavegotchi-contracts with MIT License 6 votes vote down vote up
async function main() {
  const setIds = [137];

  const setInfo: WearableSetOutput[] = [
    {
      name: "Daimyogotchi",
      traitsBonuses: [7, 0, 1, 2, -1],
      wearableIds: [155, 313, 314, 315],
      allowedCollaterals: [],
    },
  ];

  let signer: Signer;

  const testing = ["hardhat", "localhost"].includes(network.name);
  if (testing) {
    await network.provider.request({
      method: "hardhat_impersonateAccount",
      params: [itemManagerAlt],
    });
    signer = await ethers.provider.getSigner(itemManagerAlt);
  } else if (network.name === "matic") {
    signer = (await ethers.getSigners())[0];
  } else {
    throw Error("Incorrect network selected");
  }

  const daoFacet = (await ethers.getContractAt(
    "DAOFacet",
    maticDiamondAddress,
    signer
  )) as DAOFacet;

  const tx = await daoFacet.updateWearableSets(setIds, setInfo);
  console.log("tx hash:", tx.hash);
  await tx.wait();
  console.log("Updated wearable sets");
}
Example #6
Source File: kms-ethers-signer.ts    From cloud-cryptographic-wallet with MIT License 6 votes vote down vote up
export class KmsEthersSigner extends Signer {
  private readonly kmsSigner: KmsSigner;
  private readonly adapter: Adapter;

  constructor(
    private readonly config: KmsEthersSignerConfig,
    provider?: Provider
  ) {
    super();
    defineReadOnly(this, "provider", provider);

    this.kmsSigner = new KmsSigner(config.keyId, config.kmsClientConfig ?? {});

    this.adapter = new Adapter({ signer: this.kmsSigner, version }, provider);
  }

  async getAddress(): Promise<string> {
    return this.adapter.getAddress();
  }

  async signMessage(message: Bytes | string): Promise<string> {
    return this.adapter.signMessage(message);
  }

  async signTransaction(
    deferrableTransaction: Deferrable<TransactionRequest>
  ): Promise<string> {
    return this.adapter.signTransaction(deferrableTransaction);
  }

  connect(provider: Provider): KmsEthersSigner {
    return new KmsEthersSigner(this.config, provider);
  }
}
Example #7
Source File: multisig.ts    From ghst-staking with MIT License 6 votes vote down vote up
export async function sendToMultisig(
  multisigAddress: string,
  signer: Signer,
  transaction: PopulatedTransaction,
  ethers: any
) {
  const abi = [
    "function submitTransaction(address destination, uint value, bytes data) public returns (uint transactionId)",
  ];
  const multisigContract = await ethers.getContractAt(
    abi,
    multisigAddress,
    signer
  );

  console.log("tx to:", transaction.to);
  console.log("tx data:", transaction.data);

  console.log("Sending transaction to multisig:", multisigAddress);

  console.log("tx data:", transaction.data);

  let tx = await multisigContract.submitTransaction(
    transaction.to,
    0,
    transaction.data,
    { gasPrice: gasPrice }
  );
  let receipt = await tx.wait();
  if (!receipt.status) {
    throw Error(`Failed to send transaction to multisig: ${tx.hash}`);
  }
  console.log("Completed sending transaction to multisig:", tx.hash);
  return tx;
}
Example #8
Source File: index.ts    From ccip-read with MIT License 6 votes vote down vote up
constructor(constructorGuard: any, parent: Signer, provider: CCIPReadProvider) {
    super();

    if (constructorGuard !== _constructorGuard) {
      throw new Error('do not call the CCIPReadSigner directly; use provider.getSigner');
    }

    this.parent = parent;
    this.provider = provider;
  }
Example #9
Source File: updateItemDimensions.ts    From aavegotchi-contracts with MIT License 6 votes vote down vote up
task(
  "updateItemDimensions",
  "Updates item dimensions, given svgId and dimensions"
)
  .addParam("itemIds", "Item IDs to update dimensions")
  .addParam("dimensions", "New dimensions of each item")

  .setAction(
    async (
      taskArgs: UpdateItemDimensionsTaskArgs,
      hre: HardhatRuntimeEnvironment
    ) => {
      const itemIds: string[] = taskArgs.itemIds.split(",");
      const dimensions: Dimensions[] = convertStringToDimensionsArray(
        taskArgs.dimensions
      );

      const signer: Signer = await getDiamondSigner(hre, itemManager, false);

      const svgFacet = (await hre.ethers.getContractAt(
        "SvgFacet",
        maticDiamondAddress,
        signer
      )) as SvgFacet;

      let tx = await svgFacet.setItemsDimensions(itemIds, dimensions, {
        gasPrice: gasPrice,
      });
      console.log("tx hash:", tx.hash);
      let receipt = await tx.wait();
      console.log("New Dimensions set!");

      if (!receipt.status) {
        throw Error(`Error with transaction: ${tx.hash}`);
      }
    }
  );
Example #10
Source File: utils.ts    From sdk with ISC License 6 votes vote down vote up
export function executePopulatedTransaction(
    populatedTxn: Resolveable<PopulatedTransaction>,
    signer:       Signer,
): Promise<ContractTransaction> {
    return Promise.resolve(populatedTxn)
        .then(txn => signer.sendTransaction(txn))
        .catch(rejectPromise)
}
Example #11
Source File: updateSleeveItemId.ts    From aavegotchi-contracts with MIT License 6 votes vote down vote up
task("updateSleeves", "Updates SVGs, given sleevesIds and a list of svgIds")
  .addParam("sleevesIds", "List of sleeve IDs to add or update")
  .addParam("wearableIds", "List of SVG IDs to add or update")

  .setAction(
    async (taskArgs: UpdateSleevesTaskArgs, hre: HardhatRuntimeEnvironment) => {
      const sleeves: Sleeves[] = convertStringToSleevesArray(
        taskArgs.sleevesIds,
        taskArgs.wearableIds
      );

      const signer: Signer = await getDiamondSigner(hre, itemManager, false);
      const svgFacet = (await hre.ethers.getContractAt(
        "SvgFacet",
        maticDiamondAddress,
        signer
      )) as SvgFacet;

      let tx = await svgFacet.setSleeves(sleeves);
      console.log("tx hash:", tx.hash);
      let receipt = await tx.wait();
      console.log("Sleeve set!");
      if (!receipt.status) {
        throw Error(`Error with transaction: ${tx.hash}`);
      }
    }
  );
Example #12
Source File: signatures.ts    From balancer-v2-monorepo with GNU General Public License v3.0 5 votes vote down vote up
export async function accountToAddress(account: Account): Promise<string> {
  if (typeof account == 'string') return account;
  if (Signer.isSigner(account)) return account.getAddress();
  if (account.address) return account.address;
  throw new Error('Could not read account address');
}
Example #13
Source File: multisig.ts    From ghst-staking with MIT License 5 votes vote down vote up
export async function sendToGnosisSafe(
  hre: HardhatRuntimeEnvironment,
  multisigAddress: string,
  transaction: PopulatedTransaction,
  signer: Signer
) {
  console.log(
    `Sending to Gnosis Safe at address: ${multisigAddress} on ${hre.network.name} network`
  );

  try {
    const transactions: SafeTransactionDataPartial[] = [
      {
        to: multisigAddress,
        value: transaction.value ? transaction.value.toString() : "0",
        data: transaction.data ? transaction.data : "0x",
      },
    ];

    console.log("transactions:", transactions);

    /*const ethAdapterOwner1 = new EthersAdapter({
      ethers: hre.ethers,
      signer: signer,
    });

    const chainId = await ethAdapterOwner1.getChainId();
    console.log("chain id:", chainId);

    const safeSdk: Safe = await Safe.create({
      ethAdapter: ethAdapterOwner1,
      safeAddress: multisigAddress,
      contractNetworks: {},
    });

    const safeTransaction = await safeSdk.createTransaction(...transactions);

    await safeSdk.signTransaction(safeTransaction);
    */

    console.log("Owner has signed!");
  } catch (error) {
    console.log("Error creating txn:", error);
  }
}
Example #14
Source File: permit.ts    From balancer-v2-monorepo with GNU General Public License v3.0 5 votes vote down vote up
signPermit = async (
  token: Contract,
  owner: Signer & TypedDataSigner,
  spender: Account,
  amount: BigNumberish,
  deadline: BigNumberish = MAX_DEADLINE,
  nonce?: BigNumberish
): Promise<{ v: number; r: string; s: string; deadline: BigNumber; nonce: BigNumber }> => {
  const { chainId } = await token.provider.getNetwork();
  const ownerAddress = await owner.getAddress();

  if (!nonce) nonce = (await token.nonces(ownerAddress)) as BigNumberish;

  // Hack around some tokens not exposing a `version()` function.
  // If they do then use it, otherwise assume that their version is "1".
  let version = '1';
  try {
    if (token.version) {
      version = await token.version();
    }
  } catch {
    // eslint-disable-prev-line no-empty
  }

  const domain = {
    name: await token.name(),
    version,
    chainId,
    verifyingContract: token.address,
  };

  const types = {
    Permit: [
      { name: 'owner', type: 'address' },
      { name: 'spender', type: 'address' },
      { name: 'value', type: 'uint256' },
      { name: 'nonce', type: 'uint256' },
      { name: 'deadline', type: 'uint256' },
    ],
  };

  const value = {
    owner: ownerAddress,
    spender: await accountToAddress(spender),
    value: amount,
    nonce,
    deadline,
  };

  const signature = await owner._signTypedData(domain, types, value);
  return { ...splitSignature(signature), deadline: BigNumber.from(deadline), nonce: BigNumber.from(nonce) };
}
Example #15
Source File: burnAuction.test.ts    From hubble-contracts with MIT License 5 votes vote down vote up
describe("Bidder", function() {
    let deployer: Signer;
    let serviceSigner: Signer;
    let competitor: Signer;
    let contract: BurnAuction;
    let burnAuction: BurnAuctionWrapper;
    let bidder: Bidder;
    const willingnessToBid = BigNumber.from("1");

    beforeEach(async function() {
        [deployer, serviceSigner, competitor] = await ethers.getSigners();
        contract = await new BurnAuction__factory(deployer).deploy(
            PRODUCTION_PARAMS.DONATION_ADDRESS,
            PRODUCTION_PARAMS.DONATION_NUMERATOR
        );
        burnAuction = await BurnAuctionWrapper.fromContract(contract);

        bidder = await Bidder.new(
            willingnessToBid,
            contract.connect(serviceSigner)
        );
        const nblocks = burnAuction.initialBlocks + burnAuction.blocksPerSlot;
        await mineBlocks(ethers.provider, nblocks);
    });

    it("bids", async function() {
        const currentBlock = await ethers.provider.getBlockNumber();
        await bidder.maybeBid(currentBlock);
        assert.equal(
            (await burnAuction.getAuctioningSlotBid()).coordinator,
            await serviceSigner.getAddress()
        );
    });

    it("doesn't bid if already win", async function() {
        await contract.connect(serviceSigner).bid("1", { value: "1" });
        const currentBlock = await ethers.provider.getBlockNumber();
        // bid would result an error and thus fail the test
        await bidder.maybeBid(currentBlock);
    });

    it("doesn't bid if amount is too much", async function() {
        const amount = willingnessToBid.add("1");
        await contract.connect(competitor).bid(amount, { value: amount });
        const currentBlock = await ethers.provider.getBlockNumber();
        await bidder.maybeBid(currentBlock);
        assert.equal(
            (await burnAuction.getAuctioningSlotBid()).coordinator,
            await competitor.getAddress()
        );
    });
});
Example #16
Source File: index.ts    From limit-orders-lib with GNU General Public License v3.0 5 votes vote down vote up
constructor(
    chainId: ChainId,
    signerOrProvider?: Signer | Provider,
    handler?: Handler,
    isFlashbotsProtected = false
  ) {
    if (handler && !isValidChainIdAndHandler(chainId, handler)) {
      throw new Error("Invalid chainId and handler");
    } else if (
      isFlashbotsProtected &&
      (handler || !isFlashbotsCompatibleChainId(chainId))
    ) {
      throw new Error(
        "Invalid chainId or handler for Flashbots bundle submission. handler must be undefined, and chainId either 1 (mainnet) or 5 (goerli)"
      );
    }

    this._chainId = chainId;
    this._subgraphUrl = SUBGRAPH_URL[chainId];
    this._signer = Signer.isSigner(signerOrProvider)
      ? signerOrProvider
      : undefined;
    this._provider = Provider.isProvider(signerOrProvider)
      ? signerOrProvider
      : Signer.isSigner(signerOrProvider)
      ? signerOrProvider.provider
      : undefined;

    this._gelatoLimitOrders = this._signer
      ? GelatoLimitOrders__factory.connect(
          GELATO_LIMIT_ORDERS_ADDRESS[this._chainId],
          this._signer
        )
      : this._provider
      ? GelatoLimitOrders__factory.connect(
          GELATO_LIMIT_ORDERS_ADDRESS[this._chainId],
          this._provider
        )
      : (new Contract(
          GELATO_LIMIT_ORDERS_ADDRESS[this._chainId],
          GelatoLimitOrders__factory.createInterface()
        ) as GelatoLimitOrdersContract);
    this._moduleAddress = isFlashbotsProtected
      ? GELATO_LIMIT_ORDERS_MODULE_FLASHBOTS_ADDRESS[this._chainId]
      : GELATO_LIMIT_ORDERS_MODULE_ADDRESS[this._chainId];
    this._handler = handler;
    this._handlerAddress = handler
      ? HANDLERS_ADDRESSES[this._chainId][handler]?.toLowerCase()
      : undefined;
    this._isFlashbotsProtected = isFlashbotsProtected;

    this._abiEncoder = new utils.AbiCoder();

    this._erc20OrderRouter = this._signer
      ? ERC20OrderRouter__factory.connect(
          GELATO_LIMIT_ORDERS_ERC20_ORDER_ROUTER[this._chainId],
          this._signer
        )
      : this._provider
      ? ERC20OrderRouter__factory.connect(
          GELATO_LIMIT_ORDERS_ERC20_ORDER_ROUTER[this._chainId],
          this._provider
        )
      : (new Contract(
          GELATO_LIMIT_ORDERS_ERC20_ORDER_ROUTER[this._chainId],
          ERC20OrderRouter__factory.createInterface()
        ) as ERC20OrderRouter);
  }
Example #17
Source File: index.ts    From ccip-read with MIT License 5 votes vote down vote up
connect(_provider: Provider): Signer {
    return logger.throwError('CCIPReadSigner does not support connect', Logger.errors.NOT_IMPLEMENTED);
  }
Example #18
Source File: eip1193-bridge.ts    From bodhi.js with Apache License 2.0 5 votes vote down vote up
constructor(provider: EvmRpcProvider, signer?: Signer) {
    super();
    this.provider = provider;
    this.#impl = new Eip1193BridgeImpl(provider, signer);
  }
Example #19
Source File: multisig.ts    From aavegotchi-contracts with MIT License 5 votes vote down vote up
export async function sendToMultisig(
  multisigAddress: string,
  signer: Signer,
  transaction: PopulatedTransaction,
  ethers: any
) {
  const abi = [
    "function submitTransaction(address destination, uint value, bytes data) public returns (uint transactionId)",
  ];
  const multisigContract = await ethers.getContractAt(
    abi,
    multisigAddress,
    signer
  );
  console.log("Sending transaction to multisig:", multisigAddress);

  console.log("signer:", await signer.getAddress());

  console.log("data:", transaction.data);

  //@ts-ignore
  const feeData: FeeData = await signer.provider?.getFeeData();

  console.log("feedata:", feeData);

  let tx: ContractTransaction = await multisigContract.submitTransaction(
    transaction.to,
    0,
    transaction.data,
    { gasPrice: feeData.gasPrice.mul(5).div(2) }
  );

  console.log("tx:", tx.data);

  let receipt = await tx.wait();
  if (!receipt.status) {
    throw Error(`Failed to send transaction to multisig: ${tx.hash}`);
  }
  console.log("Completed sending transaction to multisig:", tx.hash);
  return tx;
}
Example #20
Source File: eip1193-bridge.ts    From bodhi.js with Apache License 2.0 5 votes vote down vote up
readonly #signer?: Signer;
Example #21
Source File: updateBuggedListings.ts    From aavegotchi-contracts with MIT License 4 votes vote down vote up
async function main() {
  const listingIds = [
    {
      borrower: "0xb09a51b6c346ad3b1e810dff8402210eda3dfaad",
      completed: false,
      gotchiTokenId: "17299",
      id: "27075",
      lastClaimed: "1649142587",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649097863",
      tokensToShare: [],
    },
    {
      borrower: "0x7b5129beac90bfb3e288dc48936b9690d3e12ce6",
      completed: false,
      gotchiTokenId: "18157",
      id: "27064",
      lastClaimed: "0",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649120652",
      tokensToShare: [],
    },
    {
      borrower: "0x2aa0f8f4884230b60f8d40462d70ea0df1255280",
      completed: false,
      gotchiTokenId: "13670",
      id: "27049",
      lastClaimed: "1649256774",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649093860",
      tokensToShare: [],
    },
    {
      borrower: "0x0f75fd79338e0c2e4619a285af5f536541c267e0",
      completed: false,
      gotchiTokenId: "17273",
      id: "27043",
      lastClaimed: "1649292864",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649100827",
      tokensToShare: [],
    },
    {
      borrower: "0x0000000000000000000000000000000000000000",
      completed: false,
      gotchiTokenId: "17151",
      id: "27034",
      lastClaimed: "0",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "0",
      tokensToShare: [],
    },
    {
      borrower: "0x0000000000000000000000000000000000000000",
      completed: false,
      gotchiTokenId: "17085",
      id: "27021",
      lastClaimed: "0",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "0",
      tokensToShare: [],
    },
    {
      borrower: "0xe0851f8584d6a064e178fb0f9b75bc0d5a72cd81",
      completed: false,
      gotchiTokenId: "19366",
      id: "27003",
      lastClaimed: "0",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649107743",
      tokensToShare: [],
    },
    {
      borrower: "0xffeff68bb01820bd3aa057d782f7dc9063d821e4",
      completed: false,
      gotchiTokenId: "12080",
      id: "26992",
      lastClaimed: "1649256412",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649099443",
      tokensToShare: [],
    },
    {
      borrower: "0x29de374aa1bfd52ccd0ae3d39eeeaff6f51f417e",
      completed: false,
      gotchiTokenId: "16714",
      id: "26977",
      lastClaimed: "0",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649119276",
      tokensToShare: [],
    },
    {
      borrower: "0x1d7a8620afab2bcd78d8d3181f439f21a1766076",
      completed: false,
      gotchiTokenId: "15783",
      id: "26970",
      lastClaimed: "0",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649171335",
      tokensToShare: [],
    },
    {
      borrower: "0xfd95dd06f5dcbabb8ee1d4b6556caa65e1e877bd",
      completed: false,
      gotchiTokenId: "16920",
      id: "26960",
      lastClaimed: "1649296316",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649100579",
      tokensToShare: [],
    },
    {
      borrower: "0x10b845fc843ed86fa254be8e869c0c3709574102",
      completed: false,
      gotchiTokenId: "10441",
      id: "26937",
      lastClaimed: "0",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649093966",
      tokensToShare: [],
    },
    {
      borrower: "0x91ee049fc064707446723b06731409d57f965933",
      completed: false,
      gotchiTokenId: "13457",
      id: "26915",
      lastClaimed: "1649304252",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649124998",
      tokensToShare: [],
    },
    {
      borrower: "0x0000000000000000000000000000000000000000",
      completed: false,
      gotchiTokenId: "10529",
      id: "26905",
      lastClaimed: "0",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "0",
      tokensToShare: [],
    },
    {
      borrower: "0x1cd0b90456c77502e82f051c04ccf8d293271792",
      completed: false,
      gotchiTokenId: "15258",
      id: "26560",
      lastClaimed: "0",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649102751",
      tokensToShare: [],
    },
    {
      borrower: "0x84f4c04fb3779d931354830b144d579ac86364be",
      completed: false,
      gotchiTokenId: "15080",
      id: "26547",
      lastClaimed: "1649250053",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649174308",
      tokensToShare: [],
    },
    {
      borrower: "0xaf680c6894f56b5ac7c90bf88e529f5b08151b79",
      completed: false,
      gotchiTokenId: "16007",
      id: "26534",
      lastClaimed: "0",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649097375",
      tokensToShare: [],
    },
    {
      borrower: "0x4f86814ffcb94f6e037a4e03e381b9a45dba705b",
      completed: false,
      gotchiTokenId: "13406",
      id: "26524",
      lastClaimed: "1649159173",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649093558",
      tokensToShare: [],
    },
    {
      borrower: "0xc63bd4d979df10c6999e55b9042c39a04779558d",
      completed: false,
      gotchiTokenId: "13609",
      id: "26508",
      lastClaimed: "1649207059",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649104451",
      tokensToShare: [],
    },
    {
      borrower: "0x3b273f20d9e88e3c73b9b0fa90c072a85a2c6dac",
      completed: false,
      gotchiTokenId: "11037",
      id: "26423",
      lastClaimed: "1649284430",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649094204",
      tokensToShare: [],
    },
    {
      borrower: "0xe45cc68d5c7ae44adc990b03e1d72f13d94d6d17",
      completed: false,
      gotchiTokenId: "17936",
      id: "26410",
      lastClaimed: "1649161753",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649100689",
      tokensToShare: [],
    },
    {
      borrower: "0x28d642cc669338f6885209d23896e88396b0cb57",
      completed: false,
      gotchiTokenId: "14600",
      id: "26404",
      lastClaimed: "1649313262",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649092398",
      tokensToShare: [],
    },
    {
      borrower: "0xefb9260017debeeb71e9b1290f924f02b7ddcf5b",
      completed: false,
      gotchiTokenId: "10875",
      id: "26385",
      lastClaimed: "0",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649099605",
      tokensToShare: [],
    },
    {
      borrower: "0x20049ff0d9adc8ecca90b28e59513b2bd11cce53",
      completed: false,
      gotchiTokenId: "11324",
      id: "26369",
      lastClaimed: "0",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649108549",
      tokensToShare: [],
    },
    {
      borrower: "0x557a838aab833b76cf9110e4c13dc2e85643bf8c",
      completed: false,
      gotchiTokenId: "15065",
      id: "26355",
      lastClaimed: "0",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649094206",
      tokensToShare: [],
    },
    {
      borrower: "0x5372341e072685dafbcc5d2316f983c4ff94e4d0",
      completed: false,
      gotchiTokenId: "22253",
      id: "26345",
      lastClaimed: "0",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649108687",
      tokensToShare: [],
    },
    {
      borrower: "0xcd513fbf5fdbd201f01fea4e85e505bd75a5050a",
      completed: false,
      gotchiTokenId: "11171",
      id: "26335",
      lastClaimed: "0",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649169121",
      tokensToShare: [],
    },
    {
      borrower: "0x685eef809d8503657cef8b8ed2fe8b0399935d60",
      completed: false,
      gotchiTokenId: "15437",
      id: "26329",
      lastClaimed: "0",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649102437",
      tokensToShare: [],
    },
    {
      borrower: "0xc63191904ba9df7d51041cacdcb674710933ed32",
      completed: false,
      gotchiTokenId: "12410",
      id: "26312",
      lastClaimed: "1649112081",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649092644",
      tokensToShare: [],
    },
    {
      borrower: "0x63803f3ca3bb93012de1c40091313a211c2f5301",
      completed: false,
      gotchiTokenId: "23410",
      id: "26303",
      lastClaimed: "1649252815",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649098759",
      tokensToShare: [],
    },
    {
      borrower: "0x0000000000000000000000000000000000000000",
      completed: false,
      gotchiTokenId: "17733",
      id: "26293",
      lastClaimed: "0",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "0",
      tokensToShare: [],
    },
    {
      borrower: "0x0000000000000000000000000000000000000000",
      completed: false,
      gotchiTokenId: "17733",
      id: "26279",
      lastClaimed: "0",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "0",
      tokensToShare: [],
    },
    {
      borrower: "0x0f533fd578bca9ce6a9969944e169b3e7651ba12",
      completed: false,
      gotchiTokenId: "23189",
      id: "26273",
      lastClaimed: "1649276775",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649102385",
      tokensToShare: [],
    },
    {
      borrower: "0x0000000000000000000000000000000000000000",
      completed: false,
      gotchiTokenId: "23189",
      id: "26263",
      lastClaimed: "0",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "0",
      tokensToShare: [],
    },
    {
      borrower: "0x6eb43a0fc769238d5add0380b8d5bc28596d4d9b",
      completed: false,
      gotchiTokenId: "16244",
      id: "26259",
      lastClaimed: "1649255407",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649089800",
      tokensToShare: [],
    },
    {
      borrower: "0x4c5e1d2abf794eac8897781d27845507729f7fbe",
      completed: false,
      gotchiTokenId: "20164",
      id: "26248",
      lastClaimed: "1649252845",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649089750",
      tokensToShare: [],
    },
    {
      borrower: "0x483b950f021466220343fa1e92fb232a1e8896b3",
      completed: false,
      gotchiTokenId: "20565",
      id: "26244",
      lastClaimed: "1649304750",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649171023",
      tokensToShare: [],
    },
    {
      borrower: "0x0000000000000000000000000000000000000000",
      completed: false,
      gotchiTokenId: "24023",
      id: "26242",
      lastClaimed: "0",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "0",
      tokensToShare: [],
    },
    {
      borrower: "0x0000000000000000000000000000000000000000",
      completed: false,
      gotchiTokenId: "11999",
      id: "26236",
      lastClaimed: "0",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "0",
      tokensToShare: [],
    },
    {
      borrower: "0x9a5f7a72d3cfef7396eba7f046fd599ef8f3b031",
      completed: false,
      gotchiTokenId: "17775",
      id: "26223",
      lastClaimed: "1649199293",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649104085",
      tokensToShare: [],
    },
    {
      borrower: "0xb061df7d8b0079f910325a297f008c1a15039356",
      completed: false,
      gotchiTokenId: "10702",
      id: "26200",
      lastClaimed: "0",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649106735",
      tokensToShare: [],
    },
    {
      borrower: "0x0000000000000000000000000000000000000000",
      completed: false,
      gotchiTokenId: "14838",
      id: "26196",
      lastClaimed: "0",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "0",
      tokensToShare: [],
    },
    {
      borrower: "0xf199479b5da4067d8a50d5afeea3e074c3daed01",
      completed: false,
      gotchiTokenId: "19376",
      id: "26189",
      lastClaimed: "0",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649087904",
      tokensToShare: [],
    },
    {
      borrower: "0xc710d3a855ca47ffe9c386d0d7ea9e571ba53b97",
      completed: false,
      gotchiTokenId: "14878",
      id: "26180",
      lastClaimed: "1649214127",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649117980",
      tokensToShare: [],
    },
    {
      borrower: "0x96cccd6ce7332ea5acbffba6506b08253c787680",
      completed: false,
      gotchiTokenId: "17862",
      id: "26151",
      lastClaimed: "1649290207",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649087848",
      tokensToShare: [],
    },
    {
      borrower: "0xaf7e8576431d1051a61f742e6431359aea808c0b",
      completed: false,
      gotchiTokenId: "12390",
      id: "26101",
      lastClaimed: "1649253413",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "3600",
      splitBorrower: "45",
      splitOther: "30",
      splitOwner: "25",
      timeAgreed: "1649088358",
      tokensToShare: [],
    },
    {
      borrower: "0x0000000000000000000000000000000000000000",
      completed: false,
      gotchiTokenId: "22253",
      id: "10055",
      lastClaimed: "0",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "86400",
      splitBorrower: "50",
      splitOther: "10",
      splitOwner: "40",
      timeAgreed: "0",
      tokensToShare: [],
    },
    {
      borrower: "0x0000000000000000000000000000000000000000",
      completed: false,
      gotchiTokenId: "23410",
      id: "10052",
      lastClaimed: "0",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "86400",
      splitBorrower: "50",
      splitOther: "10",
      splitOwner: "40",
      timeAgreed: "0",
      tokensToShare: [],
    },
    {
      borrower: "0x0000000000000000000000000000000000000000",
      completed: false,
      gotchiTokenId: "20164",
      id: "10037",
      lastClaimed: "0",
      lender: "0x8e3d6c8f591d73ebcf79810ebc4b3adf829d2fb6",
      period: "86400",
      splitBorrower: "50",
      splitOther: "10",
      splitOwner: "40",
      timeAgreed: "0",
      tokensToShare: [],
    },
  ];

  const newRevenueTokens = [
    "0x403E967b044d4Be25170310157cB1A4Bf10bdD0f",
    "0x44A6e0BE76e1D9620A7F76588e4509fE4fa8E8C8",
    "0x6a3E7C3c6EF65Ee26975b12293cA1AAD7e1dAeD2",
    "0x42E5E06EF5b90Fe15F853F59299Fc96259209c5C",
  ];

  let signer: Signer;

  const gameManager = "0x8D46fd7160940d89dA026D59B2e819208E714E82";

  //let owner = "0xa370f2ADd2A9Fba8759147995d6A0641F8d7C119";
  const testing = ["hardhat", "localhost"].includes(network.name);
  if (testing) {
    await network.provider.request({
      method: "hardhat_impersonateAccount",
      params: [gameManager],
    });
    signer = await ethers.provider.getSigner(gameManager);
  } else if (network.name === "matic") {
    signer = await (await ethers.getSigners())[0]; //new LedgerSigner(ethers.provider, "hid", "m/44'/60'/2'/0/0");
  } else {
    throw Error("Incorrect network selected");
  }

  const lendingFacet = (await ethers.getContractAt(
    "GotchiLendingFacet",
    maticDiamondAddress,
    signer
  )) as GotchiLendingFacet;

  let listing = await lendingFacet.getLendingListingInfo("26345");

  console.log("before listing:", listing);

  const tx = await lendingFacet.emergencyChangeRevenueTokens(
    listingIds.map((val) => val.id),
    newRevenueTokens
  );
  await tx.wait();

  listing = await lendingFacet.getLendingListingInfo("26345");

  console.log("after isting:", listing);
}
Example #22
Source File: adapter.ts    From cloud-cryptographic-wallet with MIT License 4 votes vote down vote up
export class Adapter extends Signer {
  private readonly signer: ISigner;
  private readonly logger: Logger;

  constructor(config: AdapterConfig, provider?: Provider) {
    super();

    this.signer = config.signer;
    defineReadOnly(this, "provider", provider);

    this.logger = new Logger(config.version);
  }

  async getAddress(): Promise<string> {
    const address = await this.signer.getAddress();
    return getAddress(address.toString());
  }

  async signMessage(message: Bytes | string): Promise<string> {
    const digest = hashMessage(message);
    const signature = await this.signer.sign(
      Buffer.from(digest.slice(2), "hex")
    );

    return signature.toString();
  }

  async signTransaction(
    deferrableTransaction: Deferrable<TransactionRequest>
  ): Promise<string> {
    const transaction = await resolveProperties(deferrableTransaction);

    const address = await this.getAddress();
    if (transaction.from != null) {
      if (getAddress(transaction.from) !== address) {
        this.logger.throwArgumentError(
          "transaction from address mismatch",
          "transaction.from",
          transaction.from
        );
      }
    }

    const nonce = transaction.nonce
      ? BigNumber.from(transaction.nonce).toNumber()
      : undefined;

    const unsignedTransaction: UnsignedTransaction = {
      to: transaction.to,
      nonce,
      gasLimit: transaction.gasLimit,
      gasPrice: transaction.gasPrice,
      data: transaction.data,
      value: transaction.value,
      chainId: transaction.chainId,
      type: transaction.type,
      accessList: transaction.accessList,
      maxPriorityFeePerGas: transaction.maxPriorityFeePerGas,
      maxFeePerGas: transaction.maxFeePerGas,
    };
    (
      Object.keys(unsignedTransaction) as Array<keyof UnsignedTransaction>
    ).forEach((key) => {
      if (key in unsignedTransaction && unsignedTransaction[key] == undefined) {
        delete unsignedTransaction[key];
      }
    });
    const digest = keccak256(serialize(unsignedTransaction));

    const signature = await this.signer.sign(
      Buffer.from(digest.slice(2), "hex")
    );

    const ethersSignature = splitSignature({
      v: signature.v,
      r: `0x${signature.r.toString("hex")}`,
      s: `0x${signature.s.toString("hex")}`,
    });

    return serialize(unsignedTransaction, ethersSignature);
  }

  connect(provider: Provider): Adapter {
    return new Adapter(
      { signer: this.signer, version: this.logger.version },
      provider
    );
  }
}
Example #23
Source File: addItemTypes.ts    From aavegotchi-contracts with MIT License 4 votes vote down vote up
task("addItemTypes", "Adds itemTypes and SVGs ")
  .addParam("itemManager", "Address of the item manager", "0")
  .addParam("diamondAddress", "Address of the Diamond to upgrade")
  .addParam("itemFile", "File name of the items to add")
  .addParam("svgFile", "File name of the itemType SVGs")
  .addParam("sleeveStartId", "ID of the sleeve to start at")
  .addFlag("uploadItemTypes", "Upload itemTypes")
  .addFlag("uploadWearableSvgs", "Upload the SVGs")
  .addFlag("uploadSleeveSvgs", "Upload sleeve svgs")
  .addFlag("associateSleeves", "Associate the sleeves")
  .addFlag("sendToItemManager", "Mint and send the items to itemManager")
  .addFlag("replaceWearableSvgs", "Replace wearable SVGs instead of uploading")
  .addFlag("replaceSleeveSvgs", "Replace sleeve SVGs instead of uploading")

  .setAction(
    async (taskArgs: AddItemTypesTaskArgs, hre: HardhatRuntimeEnvironment) => {
      const itemFile: string = taskArgs.itemFile;
      const diamondAddress: string = taskArgs.diamondAddress;
      const svgFile: string = taskArgs.svgFile;
      const sleeveStartId: string = taskArgs.sleeveStartId;
      const itemManager = taskArgs.itemManager;
      const sendToItemManager = taskArgs.sendToItemManager;
      const uploadItemTypes = taskArgs.uploadItemTypes;
      const uploadWearableSvgs = taskArgs.uploadWearableSvgs;
      const associateSleeves = taskArgs.associateSleeves;
      const uploadSleeveSvgs = taskArgs.uploadSleeveSvgs;
      const replaceWearableSvgs = taskArgs.replaceWearableSvgs;
      const replaceSleeveSvgs = taskArgs.replaceSleeveSvgs;

      const {
        itemTypes: currentItemTypes,
      } = require(`../data/itemTypes/${itemFile}.ts`);

      const { getWearables } = require(`../svgs/${svgFile}.ts`);
      const { sleeves, wearables } = getWearables();

      const itemTypesArray: ItemTypeOutput[] = getItemTypes(
        currentItemTypes,
        hre.ethers
      );

      const svgsArray: string[] = wearables;
      const sleeveSvgsArray: SleeveObject[] = sleeves;

      let signer: Signer;

      let owner = itemManager;
      const testing = ["hardhat", "localhost"].includes(hre.network.name);
      if (testing) {
        await hre.network.provider.request({
          method: "hardhat_impersonateAccount",
          params: [owner],
        });
        signer = await hre.ethers.provider.getSigner(owner);
      } else if (hre.network.name === "matic") {
        signer = new LedgerSigner(
          hre.ethers.provider,
          "hid",
          "m/44'/60'/2'/0/0"
        );
      } else {
        throw Error("Incorrect network selected");
      }

      let tx: ContractTransaction;
      let receipt: ContractReceipt;

      let daoFacet = (await hre.ethers.getContractAt(
        "DAOFacet",
        diamondAddress,
        signer
      )) as DAOFacet;

      let svgFacet = (await hre.ethers.getContractAt(
        "SvgFacet",
        diamondAddress,
        signer
      )) as SvgFacet;

      if (uploadItemTypes) {
        console.log("Adding items", 0, "to", currentItemTypes.length);

        tx = await daoFacet.addItemTypes(itemTypesArray, {
          gasPrice: gasPrice,
        });

        receipt = await tx.wait();
        if (!receipt.status) {
          throw Error(`Error:: ${tx.hash}`);
        }
        console.log("Items were added:", tx.hash);
      }

      if (uploadWearableSvgs) {
        console.log("Upload SVGs");
        await uploadSvgs(svgFacet, svgsArray, "wearables", hre.ethers);
      }

      if (replaceWearableSvgs) {
        await updateSvgs(
          svgsArray,
          "wearables",
          itemTypesArray.map((value) => Number(value.svgId)),
          svgFacet,
          hre
        );
      }

      if (uploadSleeveSvgs) {
        console.log("Uploading Sleeves");

        await uploadSvgs(
          svgFacet,
          sleeveSvgsArray.map((value) => value.svg),
          "sleeves",
          hre.ethers
        );
      }

      if (replaceSleeveSvgs) {
        await updateSvgs(
          sleeveSvgsArray.map((value) => value.svg),
          "sleeves",
          sleeveSvgsArray.map((_, index) => Number(sleeveStartId) + index),
          svgFacet,
          hre
        );
      }

      if (associateSleeves) {
        interface SleeveInput {
          sleeveId: BigNumberish;
          wearableId: BigNumberish;
        }

        let sleevesSvgId: number = Number(sleeveStartId);
        let sleevesInput: SleeveInput[] = [];
        for (const sleeve of sleeveSvgsArray) {
          sleevesInput.push({
            sleeveId: sleevesSvgId,
            wearableId: sleeve.id,
          });
          sleevesSvgId++;
        }

        console.log("sleeves input:", sleevesInput);

        console.log("Associating sleeves svgs with body wearable svgs.");
        tx = await svgFacet.setSleeves(sleevesInput, { gasPrice: gasPrice });
        receipt = await tx.wait();
        if (!receipt.status) {
          throw Error(`Error:: ${tx.hash}`);
        }
        console.log("Sleeves associated:", tx.hash);
      }

      if (sendToItemManager) {
        const itemIds: BigNumberish[] = [];
        const quantities: BigNumberish[] = [];
        itemTypesArray.forEach((itemType: ItemTypeOutput) => {
          itemIds.push(itemType.svgId);
          quantities.push(itemType.maxQuantity);
        });

        console.log("final quantities:", itemIds, quantities);

        console.log(`Mint prize items to Item Manager ${itemManager}`);

        tx = await daoFacet.mintItems(itemManager, itemIds, quantities, {
          gasPrice: gasPrice,
        });
        receipt = await tx.wait();
        if (!receipt.status) {
          throw Error(`Error:: ${tx.hash}`);
        }

        console.log("Prize items minted:", tx.hash);
      }
    }
  );
Example #24
Source File: deployUpgrade.ts    From ghst-staking with MIT License 4 votes vote down vote up
task(
  "deployUpgrade",
  "Deploys a Diamond Cut, given an address, facets and addSelectors, and removeSelectors"
)
  .addParam("diamondUpgrader", "Address of the multisig signer")
  .addParam("diamondAddress", "Address of the Diamond to upgrade")
  .addParam(
    "facetsAndAddSelectors",
    "Stringified array of facet names to upgrade, along with an array of add Selectors"
  )
  .addOptionalParam("initAddress", "The facet address to call init function on")
  .addOptionalParam("initCalldata", "The calldata for init function")
  .addFlag(
    "useMultisig",
    "Set to true if multisig should be used for deploying"
  )
  .addFlag("useLedger", "Set to true if Ledger should be used for signing")
  // .addFlag("verifyFacets","Set to true if facets should be verified after deployment")

  .setAction(
    async (taskArgs: DeployUpgradeTaskArgs, hre: HardhatRuntimeEnvironment) => {
      const facets: string = taskArgs.facetsAndAddSelectors;
      const facetsAndAddSelectors: FacetsAndAddSelectors[] =
        convertStringToFacetAndSelectors(facets);
      const diamondUpgrader: string = taskArgs.diamondUpgrader;
      const diamondAddress: string = taskArgs.diamondAddress;
      const useMultisig = taskArgs.useMultisig;
      const useLedger = taskArgs.useLedger;
      const initAddress = taskArgs.initAddress;
      const initCalldata = taskArgs.initCalldata;

      //Instantiate the Signer
      let signer: Signer;
      const owner = await (
        (await hre.ethers.getContractAt(
          "OwnershipFacet",
          diamondAddress
        )) as OwnershipFacet
      ).owner();
      const testing = ["hardhat", "localhost"].includes(hre.network.name);

      if (testing) {
        await hre.network.provider.request({
          method: "hardhat_impersonateAccount",
          params: [owner],
        });
        signer = await hre.ethers.getSigner(owner);
      } else if (hre.network.name === "matic") {
        if (useLedger) {
          signer = new LedgerSigner(hre.ethers.provider);
        } else signer = (await hre.ethers.getSigners())[0];
      } else {
        throw Error("Incorrect network selected");
      }

      //Create the cut
      const deployedFacets = [];
      const cut: Cut[] = [];

      for (let index = 0; index < facetsAndAddSelectors.length; index++) {
        const facet = facetsAndAddSelectors[index];

        const factory = (await hre.ethers.getContractFactory(
          facet.facetName
        )) as ContractFactory;
        const deployedFacet: Contract = await factory.deploy({
          gasPrice: gasPrice,
        });
        await deployedFacet.deployed();
        console.log(
          `Deployed Facet Address for ${facet.facetName}:`,
          deployedFacet.address
        );
        deployedFacets.push(deployedFacet);

        //Verify
        if (hre.network.name === "matic") {
          // await hre.run("verify:verify", {
          //   address: deployedFacet.address,
          //   constructorArguments: [],
          // });
        }

        const newSelectors = getSighashes(facet.addSelectors, hre.ethers);

        const removeSelectors = getSighashes(facet.removeSelectors, hre.ethers);

        let existingFuncs = getSelectors(deployedFacet);

        console.log("existing funcs:", existingFuncs);
        for (const selector of newSelectors) {
          if (!existingFuncs.includes(selector)) {
            const index = newSelectors.findIndex((val) => val == selector);

            throw Error(
              `Selector ${selector} (${facet.addSelectors[index]}) not found`
            );
          }
        }

        // console.log("funcs:", existingFuncs.length);

        let existingSelectors = getSelectors(deployedFacet);
        existingSelectors = existingSelectors.filter(
          (selector) => !newSelectors.includes(selector)
        );

        // console.log("existing selectors:", existingSelectors);

        // console.log("funcs:", existingSelectors.length);

        if (newSelectors.length > 0) {
          cut.push({
            facetAddress: deployedFacet.address,
            action: FacetCutAction.Add,
            functionSelectors: newSelectors,
          });
        }

        //Always replace the existing selectors to prevent duplications

        //remove extra selectors

        // existingSelectors = existingSelectors.filter(
        //   (selector) => !extra.includes(selector)
        // );

        if (existingSelectors.length > 0)
          cut.push({
            facetAddress: deployedFacet.address,
            action: FacetCutAction.Replace,
            functionSelectors: existingSelectors,
          });

        if (removeSelectors.length > 0) {
          cut.push({
            facetAddress: hre.ethers.constants.AddressZero,
            action: FacetCutAction.Remove,
            functionSelectors: removeSelectors,
          });
        }
      }

      console.log(cut);

      //Execute the Cut
      const diamondCut = (await hre.ethers.getContractAt(
        "IDiamondCut",
        diamondAddress,
        signer
      )) as IDiamondCut;

      if (testing) {
        console.log("Diamond cut");
        const tx: ContractTransaction = await diamondCut.diamondCut(
          cut,
          initAddress ? initAddress : hre.ethers.constants.AddressZero,
          initCalldata ? initCalldata : "0x",
          { gasLimit: 8000000 }
        );
        console.log("Diamond cut tx:", tx.hash);
        const receipt: ContractReceipt = await tx.wait();
        if (!receipt.status) {
          throw Error(`Diamond upgrade failed: ${tx.hash}`);
        }
        console.log("Completed diamond cut: ", tx.hash);
      } else {
        //Choose to use a multisig or a simple deploy address
        if (useMultisig) {
          console.log("Diamond cut");
          const tx: PopulatedTransaction =
            await diamondCut.populateTransaction.diamondCut(
              cut,
              initAddress ? initAddress : hre.ethers.constants.AddressZero,
              initCalldata ? initCalldata : "0x",
              { gasLimit: 800000 }
            );
          await sendToMultisig(diamondUpgrader, signer, tx, hre.ethers);
        } else {
          const tx: ContractTransaction = await diamondCut.diamondCut(
            cut,
            initAddress ? initAddress : hre.ethers.constants.AddressZero,
            initCalldata ? initCalldata : "0x",
            { gasLimit: 800000, gasPrice: gasPrice }
          );

          const receipt: ContractReceipt = await tx.wait();
          if (!receipt.status) {
            throw Error(`Diamond upgrade failed: ${tx.hash}`);
          }
          console.log("Completed diamond cut: ", tx.hash);
        }
      }
    }
  );
Example #25
Source File: mintBaadgeSvgs.ts    From aavegotchi-contracts with MIT License 4 votes vote down vote up
task("mintBaadgeSvgs", "Adds itemTypes and SVGs")
  .addParam("itemManager", "Address of the item manager", "0")
  .addParam("itemFile", "File name of the items to add")
  .addFlag("uploadItemTypes", "Upload itemTypes")
  .addFlag("sendToItemManager", "Mint and send the items to itemManager")

  .setAction(
    async (taskArgs: MintBaadgeTaskArgs, hre: HardhatRuntimeEnvironment) => {
      console.log("item manager:", taskArgs.itemManager);

      if (taskArgs.itemManager !== itemManagerAlt) {
        throw new Error("Wrong item manager");
      }

      const itemFile: string = taskArgs.itemFile;
      const itemManager = taskArgs.itemManager;
      const sendToItemManager = taskArgs.sendToItemManager;
      const uploadItemTypes = taskArgs.uploadItemTypes;

      const {
        itemTypes: currentItemTypes,
      } = require(`../scripts/addItemTypes/itemTypes/${itemFile}.ts`);

      const itemTypesArray: ItemTypeOutput[] =
        getBaadgeItemTypes(currentItemTypes);

      let signer: Signer;

      let owner = itemManager;
      const testing = ["hardhat", "localhost"].includes(hre.network.name);
      if (testing) {
        await hre.network.provider.request({
          method: "hardhat_impersonateAccount",
          params: [owner],
        });
        signer = await hre.ethers.provider.getSigner(owner);
      } else if (hre.network.name === "matic") {
        signer = await (await hre.ethers.getSigners())[0];
        // signer = new LedgerSigner(
        //   hre.ethers.provider,
        //   "hid",
        //   "m/44'/60'/2'/0/0"
        // );
      } else {
        throw Error("Incorrect network selected");
      }

      console.log("signer:", await signer.getAddress());

      let tx: ContractTransaction;
      let receipt: ContractReceipt;

      let daoFacet = (await hre.ethers.getContractAt(
        "DAOFacet",
        maticDiamondAddress,
        signer
      )) as DAOFacet;

      if (uploadItemTypes) {
        console.log("Adding items", 0, "to", currentItemTypes.length);

        tx = await daoFacet.addItemTypes(itemTypesArray, {
          gasPrice: gasPrice,
        });

        console.log("tx hash:", tx.hash);

        receipt = await tx.wait();
        if (!receipt.status) {
          throw Error(`Error:: ${tx.hash}`);
        }
        console.log("Items were added:", tx.hash);
      }

      if (sendToItemManager) {
        const itemIds: BigNumberish[] = [];
        const quantities: BigNumberish[] = [];
        currentItemTypes.forEach((itemType: ItemTypeOutput) => {
          itemIds.push(itemType.svgId);
          quantities.push(itemType.maxQuantity);
        });

        console.log("final quantities:", itemIds, quantities);

        console.log(`Mint prize items to Item Manager ${itemManager}`);

        tx = await daoFacet.mintItems(itemManager, itemIds, quantities, {
          gasPrice: gasPrice,
        });
        receipt = await tx.wait();
        if (!receipt.status) {
          throw Error(`Error:: ${tx.hash}`);
        }

        console.log("Prize items minted:", tx.hash);
      }
    }
  );
Example #26
Source File: batchTransferTickets.ts    From ghst-staking with MIT License 4 votes vote down vote up
async function batchTicketTransfer() {
  const accounts = await ethers.getSigners();

  const itemManager = "0x8D46fd7160940d89dA026D59B2e819208E714E82";

  let testing = ["hardhat"].includes(network.name);
  let signer: Signer;

  if (testing) {
    await network.provider.request({
      method: "hardhat_impersonateAccount",
      params: [itemManager],
    });
    signer = await ethers.provider.getSigner(itemManager);
  } else if (network.name === "matic") {
    signer = accounts[0];
  } else {
    throw Error("Incorrect network selected");
  }

  //an array of the addresses to receive the tickets
  const addresses: string[] = [
    "0xE5561F7eADD55bEbdba7e06888804f6AD37DBcf9",
    "0x511e675011856fa5C751de284F7A8046c5e7c78d",
    "0x3837E3E1901CC309aaBAc1F610D440323DC840d2",
    "0x9E78fb8009251aa4c16f7D4C518Baac58d893865",
    "0xCcC8076Af1FE7fde7c638567081B82596e27cB02",
    "0x1A42216475319C6Ed13992a30D2C4E763acF7d85",
    "0x7d9489BBcC62e6b98d2A4374169952152EAf7DaE",
    "0x8a724CB32348b7a7fe6C7aB7eD722ff9869C7743",
    "0x9bfA3531738D37f2160850E14f1C4663dae03d37",
    "0x8b2b6937213a40518C105829c5865A37e2e6c592",
    "0x0c535F59104A9d296fe6bb24274ab5567AbAeFD4",
    "0xf937a09d904D2bE9636AaA72980ef77BCF9233e1",
    "0xf7b3E12Dd62F13eca44D2863f391a7f0263c07b3",
    "0x90abde24d5de0f94f416c322f694602a644600e2",
    "0x3AF09684f77Fa6Fb566dc9f8656b25493068bE29",
    "0xa915023B3eD1e00E078789e63de079b4D6dCc348",
    "0x92E216ac6Dcd7D67F138443f95fDc83bD7dd398f",
    "0x59B5Be6db0753942ECcBA68A4c44576C02e8fC03",
    "0x08cb3bDFe552FC12A1B682893A0d9FF6dbD3a52B",
    "0x92E216ac6Dcd7D67F138443f95fDc83bD7dd398f",
    "0x92E216ac6Dcd7D67F138443f95fDc83bD7dd398f",
    "0x4D72fC4a30C7F50964BbbdC7463C9aD074B3719d",
    "0xb436141073EFE6C21aC6BE9A5Bb0D1D74F0ce87C",
    "0x0B7deA71cd3bb23d35dF0374c81467176A081693",
    "0x24361DF8A930D0781C550ed6C18dA49eF8948988",
    "0x99655CA16C742b46A4a05AFAf0f7798C336Fd279",
    "0x1A4394ad3d5B6A40D0528d586f2eDb282a847399",
    "0x6687fABfA33E2b342877E33bEc742C703968036f",
    "0xB5a6D0F698E58C6E5bc1B9A7Ff402419F585F0E2",
    "0x2879fd9866607223BF11545F4F252Db94c36c5e7",
    "0x2879fd9866607223BF11545F4F252Db94c36c5e7",
    "0x6653025323a6f7c97db8CaC9E6643F45e24EF318",
    "0x24361DF8A930D0781C550ed6C18dA49eF8948988",
    "0x697203445B51cc43664EeB8D87dB3117425b3F52",
    "0xb55988515fa7e7699da8770a714722816e254966",
    "0x1F67848e80FB9854cc0D16A184562467b0738BE5",
    "0xa080C96dbaa0C49a19aDEB5AB0149638F3c493Af",
    "0x3837E3E1901CC309aaBAc1F610D440323DC840d2",
    "0x2CD41AA2CB6E901c2973d61952C1747b1e269a52",
    "0xa257263e2f79b4c5F9641257387193e5E43ebca9",
    "0xA6c37993267085450aDE3b63636A25b61Ec3925c",
    "0xa915023b3ed1e00e078789e63de079b4d6dcc348",
    "0xedb75bfcd48d2e55b96cc08baa6b930747506db8",
    "0x815446DBC3f21D4710Cc504864C444837986a86C",
    "0x00a3D4e0134Ff2046e9C9B83D3321625bA3DA1Bd",
    "0xb7203c834b373a3c779db2c302C6b386D522E6e3",
    "0x90c375B8acdf8ab6a8978E39ea8Cc280a6b8797e",
    "0x8EA8721F27eFcAaBB3901Ed6756505Ab873F15a7",
    "0xD400cB2c06bd59b1Cf15CB7794182AF4843C8341",
    "0x88d985Df3e4a636f0B6663742fe7200Bb4956642",
    "0xaB88533C1D07c777057ea130c9A167d674Db92FC",
    "0x084d54bc4Ed9D856b9D8Fa79AcCC79A81eC9Ec94",
    "0x80fb192D3f73c8AF8051ee4F59B9Eccf30A4DCf3",
    "0xedb75bfcd48d2e55b96cc08baa6b930747506db8",
    "0x35F87CF2c34137314D133E6B95A8CbD31DE82301",
    "0xE21236307F8A1c4C97e05e62373791F6d2911fe7",
    "0xffe7bcEaC39f5AbCBe2588CBF0407d2213f11105",
    "0xedb75bfcd48d2e55b96cc08baa6b930747506db8",
    "0xEdB75bfCD48d2E55B96CC08bAA6b930747506DB8",
    "0x5A42c9Dde8b182ff69209B43C0Aed1750782A579",
    "0x079e2fca2a993D64029c67DD6e05F07ffEc0B427",
    "0xCfd5297778D979c2e24b35A3C96Fb77cFDF811e7",
    "0xCfd5297778D979c2e24b35A3C96Fb77cFDF811e7",
    "0x4bC9f77B776533FD8e1c977Ff5cF28b2B5955539",
    "0xe2F8ffA704474259522Df3B49F4F053d2e47Bf98",
    "0xAA3fCD37B7F61f97F18184dFCAa62106Da622eAF",
    "0xCfd5297778D979c2e24b35A3C96Fb77cFDF811e7",
    "0x2170199E6ef61E8e4f9CBD899a2428127dEBdEc8",
    "0x35F87CF2c34137314D133E6B95A8CbD31DE82301",
    "0x4cCFe436F73668084746750267D4BF06dB02A037",
    "0x6365dB1621410Bf4BFAFB18fcdA74c172D7BDDC7",
    "0x9c7ca7CEd42e10baCA84F17D7153b2f27Ce61DB7",
    "0xf7b3E12Dd62F13eca44D2863f391a7f0263c07b3",
    "0x8156f6097EF7df6dD34ef2b351B327F48093060B",
    "0xe2F8ffA704474259522Df3B49F4F053d2e47Bf98",
    "0x06743B3Df2b5bb0c8288aaCa4BaCd3301Ef8d170",
    "0x80fb192D3f73c8AF8051ee4F59B9Eccf30A4DCf3",
    "0x3f571BdEEfde53185f5AC1A7E63BdB31F97d0F0D",
    "0xE29054172DfCBAdcBFA9FBB98edc84dBD4531FaF",
    "0x477c8E224258affFa3Ca285EE53f424026b3Bc38",
    "0xb7203c834b373a3c779db2c302C6b386D522E6e3",
    "0x7209A9C945EAcFF92e758df0B9E194e692B5Ebea",
    "0xe817a3df429c30D8418Efc23CCfcfE2c79962fDe",
    "0x6687fABfA33E2b342877E33bEc742C703968036f",
    "0x42cAe2ed6f5cC6EB4e92AE78A865bAa7EE2010fe",
    "0x8EA8721F27eFcAaBB3901Ed6756505Ab873F15a7",
    "0xBB363D5b6e091B16A93060EBb1DFC14c63a11DD9",
    "0x3293dE4513A9b8f6683f46672c991E87dE6C5839",
    "0xb436141073EFE6C21aC6BE9A5Bb0D1D74F0ce87C",
    "0x2879fd9866607223BF11545F4F252Db94c36c5e7",
    "0x1EF376Eb7D4e5BEb4119CE5BB1fF4B6E03E436B9",
    "0xDda192059EC84e2Bb056Ada945297d768BB3276A",
    "0x24361DF8A930D0781C550ed6C18dA49eF8948988",
    "0xCFf501d840CFC644AE2B5071195005581E5A83f8",
    "0x9FAa1ae9C60A800852498a6BE1C046F413292112",
    "0x54D35105Dcb34Df8ae1648b3710380600E7558Ba",
    "0xa499Df2Bdae854093e5576c26C9e53E1b30d25E5",
    "0x37DE670aE6F6D247033fa84Cff1Cd4c81c8f1a5A",
    "0xa3e0c05cdf9bbd82bf3b8413d7a2fa2d78a3b5ed",
    "0x697203445B51cc43664EeB8D87dB3117425b3F52",
    "0xF738db2E863D5a5be1DD25c63A995184e74FFbDA",
    "0x35EDaC24f1656265B9E30e546617564b7a9D97fd",
    "0x91e545f09a8519cc555672964b8fc38107409e65",
    "0x04556062C1815f5707096112BDDd4A474bF434e4",
    "0xA9BE254316BC272E90892Ca422280d487FFf74b3",
    "0x65a43DD2a44356748e12c32F1Bb503DC2634Af40",
    "0x2571e1b1C0Afbb4F3927615C38879de43B866081",
    "0xedb75bfcd48d2e55b96cc08baa6b930747506db8",
    "0xa257263e2f79b4c5f9641257387193e5e43ebca9",
    "0x5A42c9Dde8b182ff69209B43C0Aed1750782A579",
    "0x00a3D4e0134Ff2046e9C9B83D3321625bA3DA1Bd",
    "0xa257263e2f79b4c5f9641257387193e5e43ebca9",
  ];

  const ticketId = 6; //dropTicketId
  const value = 1; //1 ticket per address

  const ticketsI = (await ethers.getContractAt(
    "TicketsFacet",
    maticStakingAddress,
    signer
  )) as IERC1155;

  for (let index = 0; index < addresses.length; index++) {
    const address = addresses[index];
    console.log(
      `Transferring ticket to ${address}, index ${index + 1} of ${
        addresses.length
      }`
    );

    const tx = await ticketsI.safeTransferFrom(
      itemManager,
      address,
      ticketId,
      value,
      [],
      {
        gasPrice: gasPrice,
      }
    );
    console.log("hash:", tx.hash);

    await tx.wait();
  }
}
Example #27
Source File: sn2BaadgeAirdropTest.ts    From aavegotchi-contracts with MIT License 4 votes vote down vote up
describe("Airdrop SZN2 Baadges", async function () {
  this.timeout(200000000);

  let aavegotchiFacet: AavegotchiFacet;

  let signer: Signer;

  before(async function () {
    signer = await ethers.getSigner(maticDiamondAddress);

    aavegotchiFacet = (await ethers.getContractAt(
      "contracts/Aavegotchi/facets/AavegotchiFacet.sol:AavegotchiFacet",
      maticDiamondAddress,
      signer
    )) as AavegotchiFacet;

    // await main();
  });

  it.only("Should airdrop szn2 rookie kin baadges", async function () {
    //rookie kin top 10
    let rookKinTopTen = await aavegotchiFacet.getAavegotchi(rookKin[9]);
    let item = rookKinTopTen.items[rookKinTopTen.items.length - 1];
    let baadge = item[item.length - 1].toString();
    let ones = baadge[baadge.length - 24];
    let tens = baadge[baadge.length - 25];
    let hundreds = baadge[baadge.length - 26];
    let concatInteger = hundreds.concat(tens, ones);

    console.log("topTenRookKin: ", concatInteger);

    expect(itemTypes[24].svgId.toString()).to.equal(concatInteger.toString());

    //rookie kin top 100
    let rookKinTop100 = await aavegotchiFacet.getAavegotchi(rookKin[99]);
    let item2 = rookKinTop100.items[rookKinTop100.items.length - 1];
    let baadge2 = item2[item2.length - 1].toString();
    let ones2 = baadge2[baadge2.length - 24];
    let tens2 = baadge2[baadge2.length - 25];
    let hundreds2 = baadge2[baadge2.length - 26];
    let concatInteger2 = hundreds2.concat(tens2, ones2);

    console.log("top100RookKin: ", concatInteger2);

    expect(itemTypes[26].svgId.toString()).to.equal(concatInteger2.toString());
  });

  it.only("Should airdrop szn2 kinship baadges", async function () {
    //kinship top 10
    let kinshipTopTen = await aavegotchiFacet.getAavegotchi(kinship[9]);
    let item = kinshipTopTen.items[kinshipTopTen.items.length - 1];
    let baadge = item[item.length - 1].toString();
    let ones = baadge[baadge.length - 24];
    let tens = baadge[baadge.length - 25];
    let hundreds = baadge[baadge.length - 26];
    let concatInteger = hundreds.concat(tens, ones);

    console.log("topTenKinship: ", concatInteger);

    expect(itemTypes[18].svgId.toString()).to.equal(concatInteger.toString());

    //kinship top 100
    let kinshipTop100 = await aavegotchiFacet.getAavegotchi(kinship[99]);
    let item2 = kinshipTop100.items[kinshipTop100.items.length - 1];
    let baadge2 = item2[item2.length - 1].toString();
    let ones2 = baadge2[baadge2.length - 24];
    let tens2 = baadge2[baadge2.length - 25];
    let hundreds2 = baadge2[baadge2.length - 26];
    let concatInteger2 = hundreds2.concat(tens2, ones2);

    console.log("top100Kinship: ", concatInteger2);

    expect(itemTypes[21].svgId.toString()).to.equal(concatInteger2.toString());
  });

  it.only("Should airdrop szn2 kinship top3 baadges", async function () {
    //1st
    let kinship1st = await aavegotchiFacet.getAavegotchi(kinship[0]);
    let item = kinship1st.items[kinship1st.items.length - 1];
    let baadge = item[item.length - 1].toString();
    let ones = baadge[baadge.length - 24];
    let tens = baadge[baadge.length - 25];
    let hundreds = baadge[baadge.length - 26];
    let concatInteger = hundreds.concat(tens, ones);

    console.log("kinship1st: ", concatInteger);

    expect(itemTypes[1].svgId.toString()).to.equal(concatInteger.toString());

    //2nd
    let kinship2nd = await aavegotchiFacet.getAavegotchi(kinship[1]);
    let item2 = kinship2nd.items[kinship2nd.items.length - 1];
    let baadge2 = item2[item2.length - 1].toString();
    let ones2 = baadge2[baadge2.length - 24];
    let tens2 = baadge2[baadge2.length - 25];
    let hundreds2 = baadge2[baadge2.length - 26];
    let concatInteger2 = hundreds2.concat(tens2, ones2);

    console.log("kinship2nd: ", concatInteger2);

    expect(itemTypes[4].svgId.toString()).to.equal(concatInteger2.toString());

    //3rd
    let kinship3rd = await aavegotchiFacet.getAavegotchi(kinship[2]);
    let item3 = kinship3rd.items[kinship3rd.items.length - 1];
    let baadge3 = item3[item3.length - 1].toString();
    let ones3 = baadge3[baadge3.length - 24];
    let tens3 = baadge3[baadge3.length - 25];
    let hundreds3 = baadge3[baadge3.length - 26];
    let concatInteger3 = hundreds3.concat(tens3, ones3);

    console.log("kinship2nd: ", concatInteger3);

    expect(itemTypes[7].svgId.toString()).to.equal(concatInteger3.toString());
  });

  it.only("Should airdrop szn2 rarity 1st baadges", async function () {
    //1st
    let rarity1st = await aavegotchiFacet.getAavegotchi(rarity[0]);
    let item = rarity1st.items[rarity1st.items.length - 1];
    let baadge = item[item.length - 1].toString();
    let ones = baadge[baadge.length - 24];
    let tens = baadge[baadge.length - 25];
    let hundreds = baadge[baadge.length - 26];
    let concatInteger = hundreds.concat(tens, ones);

    console.log("rarity1st: ", concatInteger);

    expect(itemTypes[0].svgId.toString()).to.equal(concatInteger.toString());
  });

  it.only("Should airdrop szn2 rookie xp top3 baadges", async function () {
    //1st
    let rookXP1st = await aavegotchiFacet.getAavegotchi(rookXP[0]);
    let item = rookXP1st.items[rookXP1st.items.length - 1];
    let baadge = item[item.length - 1].toString();
    let ones = baadge[baadge.length - 24];
    let tens = baadge[baadge.length - 25];
    let hundreds = baadge[baadge.length - 26];
    let concatInteger = hundreds.concat(tens, ones);

    console.log("rookXP1st: ", concatInteger);

    expect(itemTypes[12].svgId.toString()).to.equal(concatInteger.toString());

    //2nd
    let rookXP2nd = await aavegotchiFacet.getAavegotchi(rookXP[1]);
    let item2 = rookXP2nd.items[rookXP2nd.items.length - 1];
    let baadge2 = item2[item2.length - 1].toString();
    let ones2 = baadge2[baadge2.length - 24];
    let tens2 = baadge2[baadge2.length - 25];
    let hundreds2 = baadge2[baadge2.length - 26];
    let concatInteger2 = hundreds2.concat(tens2, ones2);

    console.log("kinship2nd: ", concatInteger2);

    expect(itemTypes[14].svgId.toString()).to.equal(concatInteger2.toString());

    //3rd
    let rookXP3rd = await aavegotchiFacet.getAavegotchi(rookXP[2]);
    let item3 = rookXP3rd.items[rookXP3rd.items.length - 1];
    let baadge3 = item3[item3.length - 1].toString();
    let ones3 = baadge3[baadge3.length - 24];
    let tens3 = baadge3[baadge3.length - 25];
    let hundreds3 = baadge3[baadge3.length - 26];
    let concatInteger3 = hundreds3.concat(tens3, ones3);

    console.log("kinship3rd: ", concatInteger3);

    expect(itemTypes[16].svgId.toString()).to.equal(concatInteger3.toString());
  });
});