Skip to content
This repository has been archived by the owner on Jul 29, 2022. It is now read-only.

Fix compiler issues #4

Merged
merged 1 commit into from
Jun 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions packages/as-contracts/assembly/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,6 @@ export declare function ext_hash_sha2_256(
output_ptr: i32)
: void;

export declare function ext_hash_sha2_256(
input_ptr: i32,
input_len: i32,
output_ptr: i32)
: void;

// Instantiate a contract with the specified code hash.
export declare function ext_instantiate(
code_hash_ptr: i32,
Expand Down
2 changes: 1 addition & 1 deletion packages/as-contracts/assembly/lib/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,6 @@ export namespace contract {
*/
export function setRentAllowance(value: u128): void {
const valueBuffer = value.toUint8Array();
ext_set_rent_allowance(valueBuffer.dataStart, valueBuffer.length);
ext_set_rent_allowance(valueBuffer.dataStart as i32, valueBuffer.length);
}
}
8 changes: 4 additions & 4 deletions packages/as-contracts/assembly/lib/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export namespace crypto {

export function blake2b128(value: Uint8Array): Uint8Array {
const sha256 = new Uint8Array(32);
ext_hash_blake2_128(value.dataStart, value.length, sha256.dataStart)
ext_hash_blake2_128(value.dataStart as i32, value.length, sha256.dataStart as i32)
return sha256;
}

Expand All @@ -34,7 +34,7 @@ export namespace crypto {

export function blake2b256(value: Uint8Array): Uint8Array {
const sha256 = new Uint8Array(32);
ext_hash_blake2_256(value.dataStart, value.length, sha256.dataStart)
ext_hash_blake2_256(value.dataStart as i32, value.length, sha256.dataStart as i32)
return sha256;
}

Expand All @@ -46,7 +46,7 @@ export namespace crypto {

export function keccack256(value: Uint8Array): Uint8Array {
const sha256 = new Uint8Array(32);
ext_hash_keccak_256(value.dataStart, value.length, sha256.dataStart)
ext_hash_keccak_256(value.dataStart as i32, value.length, sha256.dataStart as i32)
return sha256;
}

Expand All @@ -58,7 +58,7 @@ export namespace crypto {

export function sha256(value: Uint8Array): Uint8Array {
const sha256 = new Uint8Array(32);
ext_hash_sha2_256(value.dataStart, value.length, sha256.dataStart)
ext_hash_sha2_256(value.dataStart as i32, value.length, sha256.dataStart as i32)
return sha256;
}
}
2 changes: 1 addition & 1 deletion packages/as-contracts/assembly/lib/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ export namespace dev {
export function printLine(value: string): void {
const string = String.UTF8.encode(value);
const stringArray = Uint8Array.wrap(string);
ext_println(stringArray.dataStart, string.byteLength);
ext_println(stringArray.dataStart as i32, string.byteLength);
}
}
14 changes: 7 additions & 7 deletions packages/as-contracts/assembly/lib/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ export namespace storage{
*/
export function set(key: Uint8Array, value: Uint8Array | null): void {
if(key.length === 32) {
const pointer = value ? value!.dataStart : 0;
const pointer = value!.dataStart as i32 || 0;
const length = value ? value.length : 0;

ext_set_storage(key.dataStart, pointer, length);
ext_set_storage(key.dataStart as i32, pointer, length);
}
}

Expand All @@ -42,14 +42,14 @@ export namespace storage{
*/
export function get(key: Uint8Array): Uint8Array {
// @TODO check for key.length 32
const result = ext_get_storage(key.dataStart);
const result = ext_get_storage(key.dataStart as i32);
let value = new Uint8Array(0);

if (result === StorageResult.Value) {
const size = ext_scratch_size();
if (size > 0) {
value = new Uint8Array(size);
ext_scratch_read(value.dataStart, 0, size);
ext_scratch_read(value.dataStart as i32, 0, size);
}
}
return value;
Expand All @@ -66,7 +66,7 @@ export namespace storage{

if (size > 0) {
value = new Uint8Array(size);
ext_scratch_read(value.dataStart, 0, size);
ext_scratch_read(value.dataStart as i32, 0, size);
}
return value;
}
Expand All @@ -79,10 +79,10 @@ export namespace storage{
* of zero clears the scratch buffer.
*/
export function setScratchBuffer(data: Uint8Array): void {
ext_scratch_write(data.dataStart, data.length);
ext_scratch_write(data.dataStart as i32, data.length);
}

export function clear(key: Uint8Array): void {
ext_clear_storage(key.dataStart);
ext_clear_storage(key.dataStart as i32);
}
}
4 changes: 2 additions & 2 deletions packages/as-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"license": "Apache-2.0",
"ascMain": "assembly/index.ts",
"scripts": {
"build:optimized": "asc assembly/index.ts -b build/contract.wasm -t build/contract.wat --importMemory --noAssert --use abort= --sourceMap --validate --optimize",
"build:optimized": "asc assembly/index.ts -b build/contract.wasm -t build/contract.wat --importMemory --noAssert --use abort= --sourceMap --optimize",
"build:tsd": "asc assembly/index.ts -d build/index.d.ts",
"build": "yarn build:tsd && yarn build:optimized",
"test": "asp"
Expand All @@ -26,4 +26,4 @@
"README.md",
"LICENSE"
]
}
}
2 changes: 1 addition & 1 deletion packages/as-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"author": "Stefanie Doll",
"license": "Apache-2.0",
"scripts": {
"build:optimized": "asc assembly/index.ts -b build/types.wasm -t build/types.wat --importMemory --noAssert --use abort= --sourceMap --validate --optimize",
"build:optimized": "asc assembly/index.ts -b build/types.wasm -t build/types.wat --importMemory --noAssert --use abort= --sourceMap --optimize",
"build:tsd": "asc assembly/index.ts -d build/index.d.ts",
"build": "yarn build:tsd && yarn build:optimized",
"test": "asp"
Expand Down
2 changes: 1 addition & 1 deletion packages/as-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"main": "js/index.js",
"types": "assembly/index.ts",
"scripts": {
"build:optimized": "asc assembly/index.ts -b build/utils.wasm -t build/utils.wat --importMemory --noAssert --use abort= --sourceMap --validate --optimize",
"build:optimized": "asc assembly/index.ts -b build/utils.wasm -t build/utils.wat --importMemory --noAssert --use abort= --sourceMap --optimize",
"build:tsd": "asc assembly/index.ts -d build/index.d.ts",
"build": "yarn build:tsd && yarn build:optimized",
"test": "asp"
Expand Down
4 changes: 2 additions & 2 deletions projects/test-contract/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"types": "build/index.d.ts",
"license": "Apache-2.0",
"scripts": {
"build:optimized": "asc assembly/index.ts -b build/test-contract.wasm -t build/test-contract.wat --importMemory --noAssert --use abort= --validate --optimize",
"build:optimized": "asc assembly/index.ts -b build/test-contract.wasm -t build/test-contract.wat --importMemory --noAssert --use abort= --optimize",
"build:tsd": "asc assembly/index.ts -d build/index.d.ts",
"build": "yarn build:optimized && yarn build:tsd"
},
Expand All @@ -20,4 +20,4 @@
"@substrate/as-utils": "0.0.1",
"@as-pect/cli": "^2.7.0"
}
}
}