Skip to content

Commit

Permalink
Merge pull request #234 from kodadot/223-drop-the-base
Browse files Browse the repository at this point in the history
223 drop the base
  • Loading branch information
vikiival authored Apr 11, 2023
2 parents ebf2bba + 736e97e commit a1efbdd
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 23 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"dependencies": {
"@kodadot1/metasquid": "^0.1.5-rc.0",
"@kodadot1/minimark": "0.1.5-rc.0",
"@kodadot1/minimark": "0.1.5-rc.1",
"@kodadot1/minipfs": "^0.3.0-rc.0",
"@subsquid/archive-registry": "2.1.10",
"@subsquid/big-decimal": "^0.0.0",
Expand Down
4 changes: 2 additions & 2 deletions src/mappings/utils/consolidator.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { real, burned, plsBe, plsNotBe } from '@kodadot1/metasquid/consolidator'
import { isTransferable } from '@kodadot1/minimark/v2'
import { CollectionEntity, NFTEntity } from '../../model/generated'
import { Base, CollectionEntity, NFTEntity } from '../../model/generated'
import { BatchArg, ExtraCall, RmrkInteraction, Transfer } from './types'
import { serializer } from './serializer'

import { isAddress } from './helper'

type Entity = CollectionEntity | NFTEntity
type Entity = CollectionEntity | NFTEntity | Base

export function transferable({ transferable }: NFTEntity) {
return !!transferable
Expand Down
29 changes: 16 additions & 13 deletions src/mappings/v2/change.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
import { plsBe, real } from '@kodadot1/metasquid/consolidator'
import { plsBe } from '@kodadot1/metasquid/consolidator'
import { getOrFail as get } from '@kodadot1/metasquid/entity'
import { Optional } from '@kodadot1/metasquid/types'

import { CollectionEntity } from '../../model'
import { ChangeIssuer } from '@kodadot1/minimark/v2'
import { Base, CollectionEntity } from '../../model'
import { unwrap } from '../utils'
import { isOwnerOrElseError, withMeta } from '../utils/consolidator'
import { getInteraction } from '../utils/getters'
import { error, success } from '../utils/logger'
import { Action, Context, RmrkInteraction } from '../utils/types'
import { Action, Context } from '../utils/types'
import { getChangeIssuer } from './getters'

const OPERATION = Action.CHANGEISSUER

// TODO: can also change BASE in V2 (not implemented yet)
export async function changeIssuer(context: Context) {
let interaction: Optional<RmrkInteraction> = null
let interaction: Optional<ChangeIssuer> = null

try {
const { value, caller } = unwrap(context, getInteraction)
const { value, caller } = unwrap(context, getChangeIssuer)
interaction = value
plsBe(withMeta, interaction)
const collection = await get<CollectionEntity>(context.store, CollectionEntity, interaction.id)
plsBe<CollectionEntity>(real, collection)
isOwnerOrElseError(collection, caller)
collection.currentOwner = interaction.value

success(OPERATION, `${collection.id} from ${caller}`)
await context.store.save(collection)
const isBase = interaction.id.startsWith('base')
const entity = isBase
? await get<Base>(context.store, Base, interaction.id)
: await get<CollectionEntity>(context.store, CollectionEntity, interaction.id)
isOwnerOrElseError(entity, caller)
entity.currentOwner = interaction.value

success(OPERATION, `${entity.id} from ${caller}`)
await context.store.save(entity)
} catch (e) {
error(e, OPERATION, JSON.stringify(interaction))
}
Expand Down

0 comments on commit a1efbdd

Please sign in to comment.