Skip to content

Commit

Permalink
Fixed return type
Browse files Browse the repository at this point in the history
  • Loading branch information
leoloco committed May 6, 2024
1 parent 4917c90 commit 4c285c2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
8 changes: 4 additions & 4 deletions smart-contracts/assembly/contracts/NFT/NFT-example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ export function constructor(binaryArgs: StaticArray<u8>): void {
setOwner(new Args().add(Context.caller().toString()).serialize());
}

export function name(): string {
return _name();
export function name(): StaticArray<u8> {
return stringToBytes(_name());
}

export function symbol(): string {
return _symbol();
export function symbol(): StaticArray<u8> {
return stringToBytes(_symbol());
}

/**
Expand Down
8 changes: 8 additions & 0 deletions smart-contracts/assembly/contracts/NFT/NFT-internals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4c285c2

Please sign in to comment.