From 774c5c9545978a6c97939d526ef014f4c4fa920a Mon Sep 17 00:00:00 2001 From: Guillermo Bescos Date: Mon, 30 Oct 2023 11:31:05 +0000 Subject: [PATCH] Remove idl --- frontend/claim_sdk/claim.ts | 66 ------------------------------------- 1 file changed, 66 deletions(-) diff --git a/frontend/claim_sdk/claim.ts b/frontend/claim_sdk/claim.ts index 7c20aa1f..196c5e35 100644 --- a/frontend/claim_sdk/claim.ts +++ b/frontend/claim_sdk/claim.ts @@ -1,9 +1,7 @@ import * as anchor from '@coral-xyz/anchor' import { PublicKey } from '@solana/web3.js' -import tokenDispenser from './idl/token_dispenser.json' import { ethers } from 'ethers' import { removeLeading0x } from './index' -import { HexString } from 'aptos' // Must be kept in line with the database types and the on-chain program export type Ecosystem = @@ -30,70 +28,6 @@ export class ClaimInfo { public identity: string, public amount: anchor.BN ) {} - - /** Get the serialized form of this claim info that is stored as leaves in the merkle tree. */ - public toBuffer(): Buffer { - let identityStruct: any = undefined - switch (this.ecosystem) { - case 'discord': { - identityStruct = { discord: { username: this.identity } } - break - } - case 'solana': { - identityStruct = { - solana: { pubkey: new PublicKey(this.identity).toBuffer() }, - } - break - } - case 'evm': { - identityStruct = { - evm: { - pubkey: Array.from(ethers.getBytes(this.identity)), - }, - } - break - } - case 'cosmwasm': { - identityStruct = { - cosmwasm: { address: this.identity }, - } - break - } - case 'injective': { - identityStruct = { - injective: { address: this.identity }, - } - break - } - case 'aptos': { - identityStruct = { - aptos: { - address: Buffer.from(removeLeading0x(this.identity), 'hex'), - }, - } - break - } - case 'sui': { - identityStruct = { - sui: { - address: Buffer.from(removeLeading0x(this.identity), 'hex'), - }, - } - break - } - default: { - // TODO: support the other ecosystems - throw new Error(`unknown ecosystem type: ${this.ecosystem}`) - } - } - - const coder = new anchor.BorshCoder(tokenDispenser as anchor.Idl) - // type ascription needed because typescript doesn't think the two buffer types are equal for some reason. - return coder.types.encode('ClaimInfo', { - amount: this.amount, - identity: identityStruct, - }) as Buffer - } } export function getMaxAmount(claimInfos: ClaimInfo[]): anchor.BN {