diff --git a/frontend/integration/api.ts b/frontend/integration/api.ts index 7e99deb6..6535dfb0 100644 --- a/frontend/integration/api.ts +++ b/frontend/integration/api.ts @@ -72,7 +72,7 @@ export async function handlerAmountAndProof( } else { res.status(200).json({ amount: result.amount, - proof: result.proof, + proof: result.proof_of_inclusion, address: identity, }) } diff --git a/frontend/integration/integrationTest.test.ts b/frontend/integration/integrationTest.test.ts index da12621e..3fff9b06 100644 --- a/frontend/integration/integrationTest.test.ts +++ b/frontend/integration/integrationTest.test.ts @@ -23,23 +23,8 @@ import { ethers } from 'ethers' import { addTestWalletsToDatabase as addTestWalletsToInMemoryDb, clearInMemoryDb, - getInMemoryDb, } from './utils' -function getDatabasePool() { - return { - end: async () => {}, - } -} - -async function clearDatabase(..._: any[]) {} - -async function addTestWalletsToDatabase(..._: any[]) { - return [] -} - -const pool = getDatabasePool() - describe('integration test', () => { let root: Buffer let maxAmount: anchor.BN @@ -241,7 +226,7 @@ describe('integration test', () => { ).toBeTruthy() }, 40000) - it('submits a cosmwasm claim', async () => { + it('submits a terra claim', async () => { const { claimInfo, proofOfInclusion } = (await mockFetchAmountAndProof( 'terra', testWallets.terra[0].address() @@ -274,7 +259,7 @@ describe('integration test', () => { const claimantFund = await mint.getAccountInfo(claimantFundPubkey) expect( - claimantFund.amount.eq(new anchor.BN(3000000 + 6000000)) + claimantFund.amount.eq(new anchor.BN(3000000 + 7000000)) ).toBeTruthy() const { txnEvents } = @@ -301,7 +286,7 @@ describe('integration test', () => { it('submits multiple claims at once', async () => { const wallets = { - terra: testWallets.terra[0], + injective: testWallets.injective[0], osmosis: testWallets.osmosis[0], } @@ -360,50 +345,11 @@ describe('integration test', () => { expect( claimantFund.amount.eq( - new anchor.BN(3000000 + 6000000 + 6100000 + 6200000) + new anchor.BN(3000000 + 7000000 + 8000000 + 9000000) ) ).toBeTruthy() }) - it('submits an injective claim', async () => { - const wallet = testWallets.injective[0] - const { claimInfo, proofOfInclusion } = (await mockFetchAmountAndProof( - 'injective', - wallet.address() - ))! - const signedMessage = await wallet.signMessage( - tokenDispenserProvider.generateAuthorizationPayload() - ) - - await Promise.all( - await tokenDispenserProvider.submitClaims( - [ - { - claimInfo, - proofOfInclusion, - signedMessage, - }, - ], - mockfetchFundTransaction - ) - ) - - expect( - await tokenDispenserProvider.isClaimAlreadySubmitted(claimInfo) - ).toBeTruthy() - - const claimantFundPubkey = - await tokenDispenserProvider.getClaimantFundAddress() - - const claimantFund = await mint.getAccountInfo(claimantFundPubkey) - - expect( - claimantFund.amount.eq( - new anchor.BN(3000000 + 6000000 + 6100000 + 6200000 + 7000000) - ) - ).toBeTruthy() - }, 40000) - it('submits an aptos claim', async () => { const wallet = testWallets.aptos[0] const { claimInfo, proofOfInclusion } = (await mockFetchAmountAndProof( @@ -438,9 +384,7 @@ describe('integration test', () => { expect( claimantFund.amount.eq( - new anchor.BN( - 3000000 + 6000000 + 6100000 + 6200000 + 7000000 + 5000000 - ) + new anchor.BN(3000000 + 7000000 + 8000000 + 9000000 + 6000000) ) ).toBeTruthy() }) @@ -484,13 +428,7 @@ describe('integration test', () => { expect( claimantFund.amount.eq( new anchor.BN( - 3000000 + - 6000000 + - 6100000 + - 6200000 + - 7000000 + - 5000000 + - 1000000 + 3000000 + 7000000 + 8000000 + 9000000 + 6000000 + 1000000 ) ) ).toBeTruthy() @@ -530,14 +468,7 @@ describe('integration test', () => { expect( claimantFund.amount.eq( new anchor.BN( - 3000000 + - 6000000 + - 6100000 + - 6200000 + - 7000000 + - 5000000 + - 1000000 + - 2000000 + 3000000 + 7000000 + 8000000 + 9000000 + 6000000 + 1000000 + 2000000 ) ) ).toBeTruthy() @@ -579,11 +510,10 @@ describe('integration test', () => { claimantFund.amount.eq( new anchor.BN( 3000000 + - 6000000 + - 6100000 + - 6200000 + 7000000 + - 5000000 + + 8000000 + + 9000000 + + 6000000 + 1000000 + 2000000 + 4000000 @@ -591,6 +521,7 @@ describe('integration test', () => { ) ).toBeTruthy() }, 40000) + it('fails to submit a duplicate claim', async () => { const wallet = testWallets.sui[0] const { claimInfo, proofOfInclusion } = (await mockFetchAmountAndProof( @@ -615,6 +546,7 @@ describe('integration test', () => { ) expect(JSON.stringify(res[0]).includes('InstructionError')).toBeTruthy() }) + it('eventSubscriber parses error transaction logs', async () => { const { txnEvents, failedTxnInfos } = await tokenDispenserEventSubscriber.parseTransactionLogs() diff --git a/frontend/integration/utils.ts b/frontend/integration/utils.ts index fc3e5b9e..0d1856ed 100644 --- a/frontend/integration/utils.ts +++ b/frontend/integration/utils.ts @@ -1,17 +1,12 @@ import 'dotenv/config' // Load environment variables from .env file import * as anchor from '@coral-xyz/anchor' -import { - TestEvmWallet, - TestSolanaWallet, - TestWallet, -} from '../claim_sdk/testWallets' +import { TestWallet } from '../claim_sdk/testWallets' import { ClaimInfo, Ecosystem, Ecosystems } from '../claim_sdk/claim' import { getMaxAmount } from '../claim_sdk/claim' import { MerkleTree } from '../claim_sdk/merkleTree' const CHUNK_SIZE = 1000 -const SOLANA_ECOSYSTEM_INDEX = 2 -const EVM_ECOSYSTEM_INDEX = 3 + export const EVM_CHAINS = [ 'optimism-mainnet', 'arbitrum-mainnet', diff --git a/frontend/utils/api.ts b/frontend/utils/api.ts index 9e90f301..31f0baad 100644 --- a/frontend/utils/api.ts +++ b/frontend/utils/api.ts @@ -48,14 +48,14 @@ export function handleAmountAndProofResponse( ecosystem: Ecosystem, identity: string, status: number, - { address, amount, hashes }: any = {} + { address, amount, proof }: any = {} ): { claimInfo: ClaimInfo; proofOfInclusion: Uint8Array[] } | undefined { if (status == 404) return undefined if (status == 200) { if (identity === address) { return { claimInfo: new ClaimInfo(ecosystem, identity, new BN(amount)), - proofOfInclusion: parseProof(hashes), + proofOfInclusion: parseProof(proof), } } }