diff --git a/smart-contracts/assembly/contracts/NFT/NFT-example.ts b/smart-contracts/assembly/contracts/NFT/NFT-example.ts index d4ea73a..c44d5cf 100644 --- a/smart-contracts/assembly/contracts/NFT/NFT-example.ts +++ b/smart-contracts/assembly/contracts/NFT/NFT-example.ts @@ -55,12 +55,12 @@ export function constructor(binaryArgs: StaticArray): void { setOwner(new Args().add(Context.caller().toString()).serialize()); } -export function name(): string { - return _name(); +export function name(): StaticArray { + return stringToBytes(_name()); } -export function symbol(): string { - return _symbol(); +export function symbol(): StaticArray { + return stringToBytes(_symbol()); } /** diff --git a/smart-contracts/assembly/contracts/NFT/NFT-internals.ts b/smart-contracts/assembly/contracts/NFT/NFT-internals.ts index 8d068df..a3c7bd6 100644 --- a/smart-contracts/assembly/contracts/NFT/NFT-internals.ts +++ b/smart-contracts/assembly/contracts/NFT/NFT-internals.ts @@ -280,6 +280,14 @@ export function _transferFrom(from: string, to: string, tokenId: u256): void { _update(to, tokenId, from); } +export function _transfer(to: string, tokenId: u256): void { + assert(Storage.has(ownerKey(tokenId)), 'Nonexistent token'); + const from = Context.caller().toString(); + assert(_ownerOf(tokenId) == from, 'Unauthorized caller'); + assert(to != '', 'Unauthorized to'); + _update(to, tokenId, from); +} + /** * TOD0: Implement the safeTransferFrom function. * To do so you need to verify that the recipient is a contract and supports the ERC721Receiver interface. diff --git a/smart-contracts/assembly/contracts/NFT/__tests__/NFT-example.spec.ts b/smart-contracts/assembly/contracts/NFT/__tests__/NFT-example.spec.ts index b1ed479..c2e20b3 100644 --- a/smart-contracts/assembly/contracts/NFT/__tests__/NFT-example.spec.ts +++ b/smart-contracts/assembly/contracts/NFT/__tests__/NFT-example.spec.ts @@ -50,10 +50,10 @@ beforeEach(() => { describe('Initialization', () => { test('get name', () => { - expect(name()).toBe(NFTName); + expect(bytesToString(name())).toStrictEqual(NFTName); }); test('get symbol', () => { - expect(symbol()).toBe(NFTSymbol); + expect(bytesToString(symbol())).toStrictEqual(NFTSymbol); }); test('get owner', () => { expect(bytesToString(ownerAddress([]))).toBe(contractOwner);