Skip to content

Commit

Permalink
Removed Extra Hashing
Browse files Browse the repository at this point in the history
  • Loading branch information
arietrouw committed Nov 3, 2023
1 parent a145c49 commit 16cc2dd
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export interface ContractFunctionResult<TResult = unknown> {
export type CryptoContractFunctionCallResult<TResult = unknown> = Payload<
{
address: string
call: string
chainId: number
functionName: string
params: unknown[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,13 @@ export type ContractInfo = Payload<
export class CryptoContractDiviner<TParams extends CryptoContractDivinerParams = CryptoContractDivinerParams> extends AbstractDiviner<TParams> {
static override configSchemas = [CryptoContractDivinerConfigSchema]

protected static async findCallResult<TResult = string>(
protected static findCallResult<TResult = string>(
address: string,
functionName: string,
params: unknown[],
payloads: CryptoContractFunctionCallResult[],
): Promise<TResult | undefined> {
const callHash = await this.generateCallHash(address, functionName, params)
const foundPayload = payloads.find((payload) => payload.call === callHash)
): TResult | undefined {
const foundPayload = payloads.find((payload) => payload.functionName === functionName && payload.address === address)
return foundPayload?.result.value as TResult | undefined
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import {
CryptoContractFunctionReadWitnessConfig,
CryptoContractFunctionReadWitnessConfigSchema,
} from '@xyo-network/crypto-contract-function-read-payload-plugin'
import { PayloadHasher } from '@xyo-network/hash'
import { AnyConfigSchema } from '@xyo-network/module-model'
import { ERC721Enumerable__factory } from '@xyo-network/open-zeppelin-typechain'
import { isPayloadOfSchemaType } from '@xyo-network/payload-model'
import { WitnessParams } from '@xyo-network/witness-model'
import { BigNumber, Contract } from 'ethers'
Expand Down Expand Up @@ -56,7 +54,6 @@ export class CryptoContractFunctionReadWitness<
: { value: rawResult }
const observation: CryptoContractFunctionCallResult = {
address: validatedAddress,
call: await PayloadHasher.hashAsync(fullCallPayload),
chainId: (await contract.provider.getNetwork()).chainId,
functionName: validatedFunctionName,
params,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describeIf(process.env.INFURA_PROJECT_ID)('Erc721Sentinel', () => {
projectId: process.env.INFURA_PROJECT_ID,
projectSecret: process.env.INFURA_PROJECT_SECRET,
})

describe('report', () => {
it('specifying address', async () => {
const mnemonic = 'later puppy sound rebuild rebuild noise ozone amazing hope broccoli crystal grief'
Expand Down

0 comments on commit 16cc2dd

Please sign in to comment.