dawsbot / essential-eth

🪶 An alternative to ethers & web3 that's 10x smaller
https://eeth.dev
MIT License
306 stars 34 forks source link

invalid encoding for Arcade Airdrop #281

Closed dawsbot closed 6 months ago

dawsbot commented 6 months ago

https://etherscan.io/address/0x910a1accd978377baab783329af1dbb028d9892b#readContract

image

Here's how it's currently called:

    const claimed = await contract.claimed(
      toChecksumAddress(evmAddress),
      '0x9c76bb33425ea109e9bddd5ff9e97d10de0dc8de5d123a7c288f8387a4b2ba2d', // merkleRoot
    );

Here's a test-case to add:

import { Arcade } from './Arcade';

describe('#Arcade', () => {
  describe('#isClaimed', () => {
    test('should return is claimed "true" for user who already claimed', async () => {
      const evmAddress = '0xE38a6F2045738Ea9F5Ad425E63537BA7679Eb82e';
      const isClaimed = await Arcade.isClaimed(evmAddress);
      expect(isClaimed).toBe(true);
    });

    test('should return is claimed "false" for user who hasn"t claimed', async () => {
      const evmAddress = '0xebc665ca518203db60203d10979ed1ebc30f190f';
      const isClaimed = await Arcade.isClaimed(evmAddress);
      expect(isClaimed).toBe(false);
    });
  });
});

Here is the bad vs good outputs

{
// essential-eth
  params1: {
    to: '0x910a1accd978377baab783329af1dbb028d9892b',
    data: '0x0f2d940b000000000000000000000000e38a6f2045738ea9f5ad425e63537ba7679eb82e307839633736626233333432356561313039653962646464356666396539376431306465306463386465356431323361376332383866383338376134623262613264'
  },
  params2: 'latest'
}
{
  body: {
    jsonrpc: '2.0',
    id: 1,
    method: 'eth_call',
    params: [ [Object], 'latest' ]
  },
  ethNodeResponse: {
    jsonrpc: '2.0',
    id: 1,
    result: '0x0000000000000000000000000000000000000000000000000000000000000000'
  }
}

//ethers
{
  params1: {
    to: '0x910a1accd978377baab783329af1dbb028d9892b',
    data: '0x0f2d940b000000000000000000000000e38a6f2045738ea9f5ad425e63537ba7679eb82e9c76bb33425ea109e9bddd5ff9e97d10de0dc8de5d123a7c288f8387a4b2ba2d'
  },
  params2: 'latest'
}
{
  body: {
    method: 'eth_call',
    params: [ [Object], 'latest' ],
    id: 42,
    jsonrpc: '2.0'
  },
  ethNodeResponse: {
    jsonrpc: '2.0',
    id: 42,
    result: '0x000000000000000000000000000000000000000000000100bd33fb98ba000000'
  }
}