Skip to content

Commit

Permalink
p1
Browse files Browse the repository at this point in the history
  • Loading branch information
TarekkMA committed Jan 22, 2024
1 parent 3a28be8 commit 8102cb4
Show file tree
Hide file tree
Showing 12 changed files with 296 additions and 8 deletions.
74 changes: 70 additions & 4 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions asm-scripts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
26 changes: 26 additions & 0 deletions asm-scripts/asconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"targets": {
"debug": {
"outFile": "build/debug.wasm",
"textFile": "build/debug.wat",
"sourceMap": true,
"debug": true
},
"release": {
"outFile": "build/release.wasm",
"textFile": "build/release.wat",
"sourceMap": true,
"optimizeLevel": 3,
"shrinkLevel": 3
}
},
"options": {
"bindings": "raw",
"noExportMemory": true,
"importMemory": true,
"exportTable": false,
"importTable": false,
"exportStart": false,
"noAssert": true
}
}
11 changes: 11 additions & 0 deletions asm-scripts/assembly/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@external("host", "print")
export declare function print(i: i32): void

export function calc(): i64 {
const a = i32.load(0);
print(memory.size())
print(a);
const b = i32.load(sizeof<i32>());
print(b);
return a * b;
}
6 changes: 6 additions & 0 deletions asm-scripts/assembly/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "assemblyscript/std/assembly.json",
"include": [
"./**/*.ts"
]
}
2 changes: 2 additions & 0 deletions asm-scripts/build/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
10 changes: 10 additions & 0 deletions asm-scripts/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script type="module">
import { add } from "./build/release.js";
document.body.innerText = add(1, 2);
</script>
</head>
<body></body>
</html>
54 changes: 54 additions & 0 deletions asm-scripts/package-lock.json

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

25 changes: 25 additions & 0 deletions asm-scripts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "asm-scripts",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "node tests",
"asbuild:debug": "asc assembly/index.ts --target debug",
"asbuild:release": "asc assembly/index.ts --target release",
"asbuild": "npm run asbuild:debug && npm run asbuild:release",
"start": "npx serve ."
},
"author": "",
"license": "ISC",
"devDependencies": {
"assemblyscript": "^0.27.23"
},
"type": "module",
"exports": {
".": {
"import": "./build/release.js",
"types": "./build/release.d.ts"
}
}
}
4 changes: 4 additions & 0 deletions asm-scripts/tests/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import assert from "assert";
import { add } from "../build/debug.js";
assert.strictEqual(add(1, 2), 3);
console.log("ok");
10 changes: 8 additions & 2 deletions pallets/template/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,22 @@ repository = "https://github.com/substrate-developer-hub/substrate-node-template
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
log = "0.4.20"
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = [
"derive",
] }
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] }
scale-info = { version = "2.5.0", default-features = false, features = [
"derive",
] }
frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
wasmi = { version = "0.31.1", default-features = false }
sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }

[dev-dependencies]
sp-core = { version = "21.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
sp-io = { version = "23.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
sp-runtime = { version = "24.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }

[features]
default = ["std"]
Expand All @@ -33,7 +37,9 @@ std = [
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
"sp-runtime/std",
"scale-info/std",
"wasmi/std"
]
runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks"]
try-runtime = ["frame-support/try-runtime"]
Loading

0 comments on commit 8102cb4

Please sign in to comment.