Skip to content

Commit

Permalink
Adds Protocol and Contract-Version tags to curations
Browse files Browse the repository at this point in the history
  • Loading branch information
jim-toth committed Oct 22, 2023
1 parent faa2a4d commit 4af0f23
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/curations/authenticated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,31 @@ export default class AuthenticatedArtByCityCurations

private determineCurationSource(
type: CurationType
): { srcTxId: string, contractName: string } {
): { srcTxId: string, contractName: string, contractVersion: string } {
switch (type) {
case 'ownable':
return {
srcTxId: this.config.contracts.curation.ownable,
contractName: 'Ownable-Curation-Contract'
contractName: 'Ownable-Curation-Contract',
contractVersion: '0.0.1'
}
case 'whitelist':
return {
srcTxId: this.config.contracts.curation.whitelist,
contractName: 'Whitelist-Curation-Contract'
contractName: 'Whitelist-Curation-Contract',
contractVersion: '0.0.1'
}
case 'collaborative':
return {
srcTxId: this.config.contracts.curation.collaborative,
contractName: 'Collaborative-Curation-Contract'
contractName: 'Collaborative-Curation-Contract',
contractVersion: '0.0.1'
}
case 'collaborative-whitelist':
return {
srcTxId: this.config.contracts.curation.collaborativeWhitelist,
contractName: 'Collaborative-Whitelist-Curation-Contract'
contractName: 'Collaborative-Whitelist-Curation-Contract',
contractVersion: '0.0.1'
}
default:
throw new UnknownCurationTypeError()
Expand Down Expand Up @@ -104,12 +108,18 @@ export default class AuthenticatedArtByCityCurations
}

async create(type: CurationType, opts: CurationCreationOptions) {
const { srcTxId, contractName } = this.determineCurationSource(type)
const {
srcTxId,
contractName,
contractVersion
} = this.determineCurationSource(type)
const initialState = this.createInitialState(type, opts)
const tags = (opts.tags || []).map<Tag>(tag => new Tag(tag.name, tag.value))

tags.push(
new Tag('Protocol', 'ArtByCity'),
new Tag('Contract-Name', contractName),
new Tag('Contract-Version', contractVersion),

// ArtByCity / ArFS Entity-Type
new Tag('Entity-Type', 'curation'),
Expand Down
26 changes: 26 additions & 0 deletions test/spec/curation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,5 +248,31 @@ describe('Curation Module', () => {

expect(slugTag).to.be.undefined
})

it('adds Protocol: ArtByCity tag to curations', async () => {
await authenticatedCurations.create('ownable', {
owner: MOCK_OWNER,
title: 'My Art By City Tagged Curation'
})

const { tags } = warpMock.deployFromSourceTx.firstCall.args[0]
const protocolTag = tags?.find(tag => tag.get('name') === 'Protocol')

expect(protocolTag?.get('value')).to.equal('ArtByCity')
})

it('adds Contract-Version tag to curations', async () => {
await authenticatedCurations.create('ownable', {
owner: MOCK_OWNER,
title: 'My Art By City Tagged Curation'
})

const { tags } = warpMock.deployFromSourceTx.firstCall.args[0]
const contractVersionTag = tags?.find(
tag => tag.get('name') === 'Contract-Version'
)

expect(contractVersionTag?.get('value')).to.equal('0.0.1')
})
})
})

0 comments on commit 4af0f23

Please sign in to comment.