0xFableOrg / 0xFable

A fully on-chain trading card game. There will be elves, wizards & shit. Drama and broken friendships also.
https://twitter.com/0xFableGame
BSD 3-Clause Clear License
105 stars 38 forks source link

Vincentlaucy/add viem watch event test #122

Closed debuggingfuture closed 9 months ago

debuggingfuture commented 9 months ago

Logs of

pnpm --filter webapp test packages/webapp/src/utils/viem-learning.int.test.ts
➜  0xFable git:(vincentlaucy/add-viem-watch-event-test) ✗ make deploy
cd packages/contracts && make deploy
make[1]:
forge build
[⠒] Compiling...
No files changed, compilation skipped

## Setting up (1) EVMs.
⠁ [00:00:00] [###>--------------------------------------------] 1/14 txes (0.0s)⠁ [00:00:00] [-----------------------------------⠉ [00:00:00] [######>-----------------------------------------] 2/14 txes (0.4s)⠁ [00:00:00] [-----------------------------------⠙ [00:00:02] [##########>-------------------------------------] 3/14 txes (4.6s)⠁ [00:00:00] [-----------------------------------⠚ [00:00:04] [#############>----------------------------------] 4/14 txes (6.7s)⠁ [00:00:00] [-----------------------------------⠒ [00:00:06] [#################>------------------------------] 5/14 txes (7.8s)⠁ [00:00:00] [-----------------------------------⠂ [00:00:08] [####################>---------------------------] 6/14 txes (8.4s)⠁ [00:00:00] [-----------------------------------⠂ [00:00:10] [########################>-----------------------] 7/14 txes (8.5s)⠁ [00:00:00] [-----------------------------------⠒ [00:00:12] [###########################>--------------------] 8/14 txes (8.1s)⠁ [00:00:00] [-----------------------------------⠲ [00:00:14] [##############################>-----------------] 9/14 txes (7.3s)⠁ [00:00:00] [-----------------------------------⠴ [00:00:16] [#################################>-------------] 10/14 txes (6.3s)⠁ [00:00:00] [-----------------------------------⠤ [00:00:18] [####################################>----------] 11/14 txes (5.0s)⠁ [00:00:00] [-----------------------------------⠄ [00:00:20] [########################################>------] 12/14 txes (3.5s)⠁ [00:00:00] [-----------------------------------⠄ [00:00:22] [###########################################>---] 13/14 txes (1.8s)⠁ [00:00:00] [-----------------------------------⠤ [00:00:24] [###############################################] 14/14 txes (0.0s)⠁ [00:00:00] [-----------------------------------  CardsCollection address 0x26B862f640357268Bd2d9E95bc81553a2Aa81D7E
  Inventory address 0xA56F946D6398Dd7d9D4D9B337Cf9E0F68982ca5B
  InventoryCardsCollection address 0xFC36b64da290C0C7D43491671A4277Fc00FD2a60
  Game address 0xaB7B4c595d3cE8C85e16DA86630f2fc223B05057
  DeckAirdrop address 0xAD523115cd35a8d4E60B3C0953E0E0ac10418309
✔ Validating plugins
✔ Resolving contracts
✔ Running plugins
✔ Writing to src/generated.ts
make[1]: Leaving directory '/home/vincentlaucy/workspaces/0xFable/packages/contracts'
➜  0xFable git:(vincentlaucy/add-viem-watch-event-test) ✗ pnpm --filter webapp test packages/webapp/src/utils/viem-learning.int.test.ts

> @xfable/webapp@0.1.0 test /home/vincentlaucy/workspaces/0xFable/packages/webapp
> jest "packages/webapp/src/utils/viem-learning.int.test.ts"

  console.log
    create game

      at createGame (src/utils/viem-learning.int.test.ts:36:17)

  console.log
    {
      transactionHash: '0x1e3b1aa810186e8e226c6bc54cac46b00097f0053f5885938d2e59f1ca96e87f',
      transactionIndex: 0,
      blockHash: '0xcfe6366a427d194673e0719e8ceb152a396c1bfedd7cc465a56d39f8d1ff18e7',
      blockNumber: 1199n,
      from: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
      to: '0xab7b4c595d3ce8c85e16da86630f2fc223b05057',
      cumulativeGasUsed: 118889n,
      gasUsed: 118889n,
      contractAddress: null,
      logs: [
        {
          address: '0xab7b4c595d3ce8c85e16da86630f2fc223b05057',
          topics: [Array],
          data: '0x0000000000000000000000000000000000000000000000000000000000000001',
          blockHash: '0xcfe6366a427d194673e0719e8ceb152a396c1bfedd7cc465a56d39f8d1ff18e7',
          blockNumber: 1199n,
          transactionHash: '0x1e3b1aa810186e8e226c6bc54cac46b00097f0053f5885938d2e59f1ca96e87f',
          transactionIndex: 0,
          logIndex: 0,
          transactionLogIndex: '0x0',
          removed: false
        }
      ],
      status: 'success',
      logsBloom: '0x00000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000040000000000000000000000000020000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000002000000010000000000000000000000000000000000000000000000000000000000000000000000000000000',
      type: 'eip1559',
      effectiveGasPrice: 1000000021n
    }

      at createGame (src/utils/viem-learning.int.test.ts:50:17)

  console.log
    create game

      at createGame (src/utils/viem-learning.int.test.ts:36:17)

  console.log
    {
      transactionHash: '0x31cae7f66a8b496f820f3ea4d7ac92fc88b4b913db0f771fef6c2c94a85182c6',
      transactionIndex: 0,
      blockHash: '0xb16a88c968997f77a07bb4da3e6d905a8bfe1b0fad4f06849b89634d4cc5b1bb',
      blockNumber: 1201n,
      from: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
      to: '0xab7b4c595d3ce8c85e16da86630f2fc223b05057',
      cumulativeGasUsed: 118889n,
      gasUsed: 118889n,
      contractAddress: null,
      logs: [
        {
          address: '0xab7b4c595d3ce8c85e16da86630f2fc223b05057',
          topics: [Array],
          data: '0x0000000000000000000000000000000000000000000000000000000000000002',
          blockHash: '0xb16a88c968997f77a07bb4da3e6d905a8bfe1b0fad4f06849b89634d4cc5b1bb',
          blockNumber: 1201n,
          transactionHash: '0x31cae7f66a8b496f820f3ea4d7ac92fc88b4b913db0f771fef6c2c94a85182c6',
          transactionIndex: 0,
          logIndex: 0,
          transactionLogIndex: '0x0',
          removed: false
        }
      ],
      status: 'success',
      logsBloom: '0x00000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000040000000000000000000000000020000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000002000000010000000000000000000000000000000000000000000000000000000000000000000000000000000',
      type: 'eip1559',
      effectiveGasPrice: 1000000021n
    }

      at createGame (src/utils/viem-learning.int.test.ts:50:17)

  console.log
    watch

      at Object.<anonymous> (src/utils/viem-learning.int.test.ts:97:17)

  console.log
    [debug]createEventFilter {
      address: '0xaB7B4c595d3cE8C85e16DA86630f2fc223B05057',
      args: [ 1n ],
      event: undefined,
      events: [
        {
          type: 'event',
          anonymous: false,
          inputs: [Array],
          name: 'PlayerJoined'
        }
      ],
      fromBlock: undefined,
      strict: true,
      toBlock: undefined
    }

      at createEventFilter (../../node_modules/.pnpm/viem@1.16.6_typescript@5.2.2_zod@3.22.4/node_modules/viem/actions/public/createEventFilter.ts:184:9)

  console.log
    [debug]eth_newFilter {
      topics: [
        [
          '0x87969bc7faf902221a147b95ceba76e011c5efb0339a0a8ee7a2bb82d9cfbbd6',
          '0x0000000000000000000000000000000000000000000000000000000000000001'
        ]
      ]
    }

      at createEventFilter (../../node_modules/.pnpm/viem@1.16.6_typescript@5.2.2_zod@3.22.4/node_modules/viem/actions/public/createEventFilter.ts:206:5)

  console.log
    join game 1n

      at joinGame (src/utils/viem-learning.int.test.ts:57:17)

  console.log
    logs

      at Object.<anonymous> (src/utils/viem-learning.int.test.ts:92:21)
          at Array.forEach (<anonymous>)

  console.log
    [
      {
        address: '0xab7b4c595d3ce8c85e16da86630f2fc223b05057',
        topics: [
          '0x87969bc7faf902221a147b95ceba76e011c5efb0339a0a8ee7a2bb82d9cfbbd6',
          '0x0000000000000000000000000000000000000000000000000000000000000001'
        ],
        data: '0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266',
        blockHash: '0x715fde5fb1b96cbcd13f8cd07c7a3e7bd3efc56433b165147e7691539f710869',
        blockNumber: 1204n,
        transactionHash: '0x1c5a47e52bd6faa69dfe3082e5aa91f08f3f5f02a0865baddf196956672289ec',
        transactionIndex: 0,
        logIndex: 0,
        transactionLogIndex: '0x0',
        removed: false,
        args: {
          gameID: 1n,
          player: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'
        },
        eventName: 'PlayerJoined'
      }
    ]

      at Object.<anonymous> (src/utils/viem-learning.int.test.ts:93:21)
          at Array.forEach (<anonymous>)

  console.log
    join game completed

      at joinGame (src/utils/viem-learning.int.test.ts:71:17)

  console.log
    {
      transactionHash: '0x1c5a47e52bd6faa69dfe3082e5aa91f08f3f5f02a0865baddf196956672289ec',
      transactionIndex: 0,
      blockHash: '0x715fde5fb1b96cbcd13f8cd07c7a3e7bd3efc56433b165147e7691539f710869',
      blockNumber: 1204n,
      from: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
      to: '0xab7b4c595d3ce8c85e16da86630f2fc223b05057',
      cumulativeGasUsed: 1009710n,
      gasUsed: 1009710n,
      contractAddress: null,
      logs: [
        {
          address: '0xab7b4c595d3ce8c85e16da86630f2fc223b05057',
          topics: [Array],
          data: '0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266',
          blockHash: '0x715fde5fb1b96cbcd13f8cd07c7a3e7bd3efc56433b165147e7691539f710869',
          blockNumber: 1204n,
          transactionHash: '0x1c5a47e52bd6faa69dfe3082e5aa91f08f3f5f02a0865baddf196956672289ec',
          transactionIndex: 0,
          logIndex: 0,
          transactionLogIndex: '0x0',
          removed: false
        }
      ],
      status: 'success',
      logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080060000000000000000000000000000400000000000000000040000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000010000000000040000000000000000000000000000000000000000000000000000000000000000000',
      type: 'eip1559',
      effectiveGasPrice: 1000000021n
    }

      at joinGame (src/utils/viem-learning.int.test.ts:72:17)

  console.log
    join game 2n

      at joinGame (src/utils/viem-learning.int.test.ts:57:17)

  console.log
    logs

      at Object.<anonymous> (src/utils/viem-learning.int.test.ts:92:21)
          at Array.forEach (<anonymous>)

  console.log
    [
      {
        address: '0xab7b4c595d3ce8c85e16da86630f2fc223b05057',
        topics: [
          '0x87969bc7faf902221a147b95ceba76e011c5efb0339a0a8ee7a2bb82d9cfbbd6',
          '0x0000000000000000000000000000000000000000000000000000000000000002'
        ],
        data: '0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266',
        blockHash: '0x75d58513c0a34e596653aa512329ba4253ef766e88b8fd899ed9cb53ffa5dc20',
        blockNumber: 1206n,
        transactionHash: '0xe6195f62ba039b8929d7f3da00e9cecfa3d7c2d1e426f6c8b7ce95fd8dfcdd8a',
        transactionIndex: 0,
        logIndex: 0,
        transactionLogIndex: '0x0',
        removed: false,
        args: {
          gameID: 2n,
          player: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'
        },
        eventName: 'PlayerJoined'
      }
    ]

      at Object.<anonymous> (src/utils/viem-learning.int.test.ts:93:21)
          at Array.forEach (<anonymous>)

  console.log
    join game completed

      at joinGame (src/utils/viem-learning.int.test.ts:71:17)

  console.log
    {
      transactionHash: '0xe6195f62ba039b8929d7f3da00e9cecfa3d7c2d1e426f6c8b7ce95fd8dfcdd8a',
      transactionIndex: 0,
      blockHash: '0x75d58513c0a34e596653aa512329ba4253ef766e88b8fd899ed9cb53ffa5dc20',
      blockNumber: 1206n,
      from: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
      to: '0xab7b4c595d3ce8c85e16da86630f2fc223b05057',
      cumulativeGasUsed: 992610n,
      gasUsed: 992610n,
      contractAddress: null,
      logs: [
        {
          address: '0xab7b4c595d3ce8c85e16da86630f2fc223b05057',
          topics: [Array],
          data: '0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266',
          blockHash: '0x75d58513c0a34e596653aa512329ba4253ef766e88b8fd899ed9cb53ffa5dc20',
          blockNumber: 1206n,
          transactionHash: '0xe6195f62ba039b8929d7f3da00e9cecfa3d7c2d1e426f6c8b7ce95fd8dfcdd8a',
          transactionIndex: 0,
          logIndex: 0,
          transactionLogIndex: '0x0',
          removed: false
        }
      ],
      status: 'success',
      logsBloom: '0x04000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080020000000000000000000000000000400000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000010000000000000000000000000000000000000000000000000000000008000000000000000000000',
      type: 'eip1559',
      effectiveGasPrice: 1000000021n
    }

      at joinGame (src/utils/viem-learning.int.test.ts:72:17)

  console.log
    done
norswap commented 9 months ago

Closing this, cf. conversation here on how to test manually, but pretty easily: https://github.com/0xFableOrg/0xFable/pull/120#issuecomment-1956174194