I've started a new NEAR AssemblyScript smart contract project using near-sdk-as: 3.2.3, and I'm experiencing some errors when I try to build it.
I get these errors when I try to build my AssemblyScript code: asb --target debug.
asb --target debug
ERROR TS2304: Cannot find name 'decode'.
return decode<T>(bytes);
~~~~~~
in ~lib/near-sdk-core/util.ts(46,12)
ERROR TS2304: Cannot find name 'encode'.
this.setBytes(key, encode<T>(value));
~~~~~~
in ~lib/near-sdk-core/storage.ts(160,26)
I'm using a PersistentMap in my smart contract, and I have defined a custom class, User.
The example below only includes the minimal code necessary to reproduce the same error.
index.ts
import { PersistentMap} from 'near-sdk-as';
import { User } from './user';
@nearBindgen
export class Contract {
private userMap: PersistentMap<string, User> = new PersistentMap<string, User>('users');
getUser(username: string): User {
return this.userMap.getSome(username);
}
}
user.ts
@nearBindgen
export class User {
private _username: string = '';
constructor(username: string) {
this._username = username;
}
}