Skip to content

Commit

Permalink
Fetches curation tx by curation id
Browse files Browse the repository at this point in the history
  • Loading branch information
jim-toth committed Oct 22, 2023
1 parent d35cc6e commit 71f2fee
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
15 changes: 13 additions & 2 deletions src/curations/curations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,21 @@ export default class ArtByCityCurations {
}

async getTransaction(curationId: string): Promise<ArdbTransaction | null> {
console.log('curationId', curationId)

// const tx = await this.ardb
// .search('transaction')
// .id(curationId)
// .sort('HEIGHT_DESC')
// .findOne() as ArdbTransaction

// return tx

const txs = await this.ardb
.search('transactions')
.id(curationId)
.findAll() as ArdbTransaction[]
.ids([curationId])
.sort('HEIGHT_DESC')
.find() as ArdbTransaction[]

return txs[0] || null
}
Expand Down
15 changes: 6 additions & 9 deletions test/e2e/curation.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@
import('mocha') // NB: this style import makes both webpack and typescript happy
import { expect } from 'chai'
import Arweave from 'arweave'
import { JWKInterface, LoggerFactory, WarpFactory } from 'warp-contracts'
import { JWKInterface } from 'warp-contracts'

import TestweaveJWK from '../testweave-keyfile.json'
import ArtByCity, { ArtByCityConfig } from '../../src'

LoggerFactory.INST.logLevel('error')
/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment */
const jwk: JWKInterface = TestweaveJWK as JWKInterface
const jwk: JWKInterface = TestweaveJWK

// const arweave = Arweave.init({
// protocol: 'http',
// host: 'localhost',
// port: 1984
// })
// const warp = WarpFactory.forLocal()
// const config: Partial<ArtByCityConfig> = {
// environment: 'development',
// contracts: {
Expand All @@ -33,10 +32,6 @@ const arweave = Arweave.init({
host: 'arweave.net',
port: 443
})
const warp = WarpFactory.forMainnet({
inMemory: true,
dbLocation: '.art-by-city'
})
const config: Partial<ArtByCityConfig> = { environment: 'production' }

let ownableCurationContractId: string = ''
Expand Down Expand Up @@ -117,7 +112,9 @@ describe('Curation Module', () => {
it.only('fetches curation transaction by id', async () => {
const abc = new ArtByCity(arweave, config)

const tx = await abc.curations.getTransaction('eES4WS8QtO2mMprsEajd2q9eTsV_cRTh6wrjkVh5cIY')
const tx = await abc
.curations
.getTransaction('N_nbvz1vWrNI1kl0Nxefgi3Zo0p9F-onoF1mafWaKUU')

expect(tx).to.not.be.null
})
Expand Down

0 comments on commit 71f2fee

Please sign in to comment.