Skip to content

Commit

Permalink
refactor: remove some non-spec recommendations
Browse files Browse the repository at this point in the history
  • Loading branch information
TenzingSh committed May 20, 2020
1 parent 94dc974 commit 64ea533
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 39 deletions.
37 changes: 0 additions & 37 deletions contracts/assemblyscript/nep4/__tests__/main.unit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,21 +137,6 @@ describe('get_token_owner', () => {

// not sure if these are needed?
describe('nonSpec interface', () => {
it('should include several constants', () => {
expect(nonSpec.MAX_SUPPLY).toBeGreaterThan(0)
expect(nonSpec.ERROR_NO_TOKENS_CONTROLLED).toBeTruthy()
expect(nonSpec.ERROR_CALLER_ID_DOES_NOT_MATCH_EXPECTATION).toBeTruthy()
expect(nonSpec.ERROR_INVALID_TOKEN_ID).toBeTruthy()
expect(nonSpec.ERROR_CLAIMED_OWNER_DOES_NOT_OWN_TOKEN).toBeTruthy()
expect(nonSpec.ERROR_MAXIMUM_TOKEN_LIMIT_REACHED).toBeTruthy()
})

it('should expose an interface for minting', () => {
expect(() => {
nonSpec.mint_to(alice)
}).not.toThrow()
})

it('should throw if we attempt to mint more than the MAX_SUPPLY', () => {
expect(() => {
let limit = nonSpec.MAX_SUPPLY
Expand All @@ -165,26 +150,4 @@ describe('nonSpec interface', () => {
nonSpec.mint_to(alice)
}).toThrow(nonSpec.ERROR_MAXIMUM_TOKEN_LIMIT_REACHED)
})

describe('transfer_from', () => {
it('expects the token to exist', () => {
expect(() => {
const fakeToken = -1
Context.setPredecessor_account_id(bob)

transfer_from(alice, bob, fakeToken);
}).toThrow(nonSpec.ERROR_INVALID_TOKEN_ID)
})
})

describe('transfer', () => {
it('expects the token to exist', () => {
expect(() => {
const fakeToken = -1
Context.setPredecessor_account_id(bob)

transfer(bob, fakeToken);
}).toThrow(nonSpec.ERROR_INVALID_TOKEN_ID)
})
})
})
2 changes: 0 additions & 2 deletions contracts/assemblyscript/nep4/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const TOTAL_SUPPLY = 'c'

export const ERROR_NO_TOKENS_CONTROLLED = "Caller does not control any tokens."
export const ERROR_CALLER_ID_DOES_NOT_MATCH_EXPECTATION = "Caller ID does not match expectation."
export const ERROR_INVALID_TOKEN_ID = "Invalid token identifier"
export const ERROR_CLAIMED_OWNER_DOES_NOT_OWN_TOKEN = "Claimed owner does not own token"
export const ERROR_MAXIMUM_TOKEN_LIMIT_REACHED = "Maximum token limit reached."

Expand Down Expand Up @@ -89,7 +88,6 @@ export function transfer(new_owner_id: string, token_id: TokenId): void {
const predecessor = context.predecessor

// fetch token owner and assert ownership
assert(tokenToOwner.contains(token_id), ERROR_INVALID_TOKEN_ID)
const owner = tokenToOwner.getSome(token_id)
assert(owner == predecessor, ERROR_CLAIMED_OWNER_DOES_NOT_OWN_TOKEN)

Expand Down

0 comments on commit 64ea533

Please sign in to comment.