Skip to content

Commit

Permalink
Merge branch 'staging'
Browse files Browse the repository at this point in the history
  • Loading branch information
ShivanshVij committed Apr 17, 2023
2 parents c01e95a + 8c8c463 commit 53447fa
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [v0.3.17] - 2023-04-16

### Changes

- Adding the `random_get` WASI Syscall implementation to the `Typescript` Hosts's `DisabledWASI` Polyfill

## [v0.3.16] - 2023-04-15

### Changes
Expand Down Expand Up @@ -218,7 +224,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

- Initial release of the Scale Runtime library.

[unreleased]: https://github.com/loopholelabs/scale/compare/v0.3.16...HEAD
[unreleased]: https://github.com/loopholelabs/scale/compare/v0.3.17...HEAD
[v0.3.17]: https://github.com/loopholelabs/scale/compare/v0.3.17
[v0.3.16]: https://github.com/loopholelabs/scale/compare/v0.3.16
[v0.3.15]: https://github.com/loopholelabs/scale/compare/v0.3.15
[v0.3.14]: https://github.com/loopholelabs/scale/compare/v0.3.14
Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@loopholelabs/scale",
"version": "0.3.16",
"version": "0.3.17",
"description": "Scale is a highly-performant WebAssembly function runtime that enables composable, language-agnostic software development.",
"source": "ts/index.ts",
"types": "types.d.ts",
Expand Down
9 changes: 9 additions & 0 deletions ts/wasi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface RequiredFunctions extends WebAssembly.ModuleImports {
proc_exit(rval: number): number
path_open(fd: number, dirflags: number, path_ptr: number, path_len: number, oflags: number, fs_rights_base: number, fs_rights_inheriting: number, fd_flags: number, opened_fd_ptr: number): number
clock_time_get(id: number, precision: BigInt, time: number): number
random_get(buf: number, buf_len: number): void
}

export class DisabledWASI {
Expand Down Expand Up @@ -148,6 +149,13 @@ export class DisabledWASI {
return DisabledWASI.ESUCCESS;
}

public random_get(buf: number, buf_len: number): void {
let buffer = this.getDataView();
for (let i = 0; i < buf_len; i++) {
buffer.setInt8(buf+i, (Math.random() * 256) | 0);
}
}

public GetImports(): RequiredFunctions {
return {
environ_sizes_get: this.environ_sizes_get.bind(this),
Expand All @@ -166,6 +174,7 @@ export class DisabledWASI {
proc_exit: this.proc_exit.bind(this),
path_open: this.path_open.bind(this),
clock_time_get: this.clock_time_get.bind(this),
random_get: this.random_get.bind(this),
}
}
}

0 comments on commit 53447fa

Please sign in to comment.