mirror of
https://github.com/fluencelabs/assemblyscript-dice
synced 2025-04-25 08:02:14 +00:00
add getBalance
, clear input from memory
This commit is contained in:
parent
a8d0da3879
commit
fb090f3c82
@ -67,6 +67,9 @@ export class GameManager {
|
||||
}
|
||||
|
||||
getBalance(playerId: u64): Response {
|
||||
return new GetBalanceResponse(1);
|
||||
if (!this.playerBalance.has(playerId)) {
|
||||
return new ErrorResponse("There is no player with id: " + playerId.toString());
|
||||
}
|
||||
return new GetBalanceResponse(this.playerBalance.get(playerId));
|
||||
}
|
||||
}
|
||||
|
@ -16,10 +16,9 @@ export function handler(requestBytes: Uint8Array): string {
|
||||
} else if (request instanceof GetBalanceRequest) {
|
||||
return gameManager.getBalance(request.playerId).serialize();
|
||||
} else if (request instanceof UnknownRequest) {
|
||||
return new ErrorResponse("").serialize();
|
||||
return new ErrorResponse("There is no such type of request.").serialize();
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
unreachable();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
@ -35,5 +35,7 @@ export function invoke(ptr: i32, size: i32): i32 {
|
||||
store<u8>(strAddr + i, b);
|
||||
}
|
||||
|
||||
memory.free(ptr);
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user