Skip to content

Implementation Aggregator Demo #93

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions impl-aggregator/wrapper/aggregator/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build
node_modules
wrap
.polywrap
target
1 change: 1 addition & 0 deletions impl-aggregator/wrapper/aggregator/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v16.13.0
178 changes: 178 additions & 0 deletions impl-aggregator/wrapper/aggregator/Cargo.lock

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

20 changes: 20 additions & 0 deletions impl-aggregator/wrapper/aggregator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "template-wasm-rs"
version = "0.1.0"
description = "A Polywrap Wasm wrapper template written in Rust"
authors = ["Polywrap"]
repository = "https://github.com/polywrap/monorepo"
license = "MIT"
edition = "2021"

[dependencies]
polywrap-wasm-rs = { version = "0.1.0" }
serde = { version = "1.0", features = ["derive"] }

[lib]
crate-type = ["cdylib"]

[profile.release]
opt-level = 's'
lto = true
panic = 'abort'
14 changes: 14 additions & 0 deletions impl-aggregator/wrapper/aggregator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Polywrap Wasm Wrapper Template
A simple starter template for a Rust Wasm wrapper. For more information on how this project works, and a step by step on how to extend its behavior, see the documentation [here](https://docs.polywrap.io/).

# How To Run

## Install Dependencies
`nvm install && nvm use`
`yarn`

## Build
`yarn build`

## Test
`yarn test`
23 changes: 23 additions & 0 deletions impl-aggregator/wrapper/aggregator/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "template-wasm-rs",
"description": "Polywrap Rust Wrapper Template",
"private": true,
"version": "0.3.0",
"scripts": {
"build": "npx polywrap build",
"test:env:up": "npx polywrap infra up --modules=eth-ens-ipfs",
"test:env:down": "npx polywrap infra down --modules=eth-ens-ipfs",
"deploy": "npx polywrap deploy -o uris.json",
"test": "yarn test:e2e && yarn test:workflow",
"test:e2e": "yarn test:e2e:codegen && jest --passWithNoTests --runInBand --verbose",
"test:e2e:codegen": "npx polywrap app codegen -m ./src/__tests__/types/polywrap.app.yaml -g ./src/__tests__/types/wrap",
"test:workflow": "npx polywrap run -o ./workflows/output.json -v ./workflows/validator.cue ./workflows/e2e.yaml"
},
"devDependencies": {
"@types/jest": "27.0.3",
"jest": "26.6.3",
"polywrap": "0.3.0",
"ts-jest": "26.5.4",
"typescript": "4.0.7"
}
}
12 changes: 12 additions & 0 deletions impl-aggregator/wrapper/aggregator/polywrap.deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
format: 0.1.0
stages:
ipfs_deploy:
package: ipfs
uri: fs/./build
ens_publish:
package: local-dev-ens
depends_on: ipfs_deploy
config:
domainName: animals.eth
ports:
ethereum: 8545
6 changes: 6 additions & 0 deletions impl-aggregator/wrapper/aggregator/polywrap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
format: 0.1.0
name: template-wasm-rs
language: wasm/rust
deploy: ./polywrap.deploy.yaml
module: ./Cargo.toml
schema: ./src/schema.graphql
9 changes: 9 additions & 0 deletions impl-aggregator/wrapper/aggregator/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pub mod wrap;
pub use wrap::*;

pub fn get_animals(args: ArgsGetAnimals) -> Vec<String> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I belive the aggregator example should be better than this. It should actually call one or more of implementations depending on conditions.

I have an idea will do some changes in this

[
"wrap://ens/cat.impls.animals.eth".to_string(),
"wrap://ens/dog.impls.animals.eth".to_string()
].to_vec()
}
3 changes: 3 additions & 0 deletions impl-aggregator/wrapper/aggregator/src/schema.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
type Module {
getAnimals: [String!]!
}
28 changes: 28 additions & 0 deletions impl-aggregator/wrapper/aggregator/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"lib": [
"es2015",
"es5",
"dom"
],
"esModuleInterop": true,
"outDir": "build",
"moduleResolution": "node",
"declaration": true,
"preserveSymlinks": true,
"preserveWatchOutput": true,
"pretty": false,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"module": "commonjs",
"sourceMap": true,
"target": "es5",
"resolveJsonModule": true,
"strictNullChecks": true,
"experimentalDecorators": true
},
"typeAcquisition": { "include": ["jest"] }
}
24 changes: 24 additions & 0 deletions impl-aggregator/wrapper/aggregator/uris.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[
{
"id": "ipfs_deploy",
"name": "ipfs_deploy",
"input": {
"uri": "wrap://fs/./build"
},
"result": "wrap://ipfs/QmakWH6aPYDjoq1XhnRJwE7Kgq7uyBDjX19WXCEzM1cyjX"
},
{
"id": "ipfs_deploy.ens_publish",
"name": "ens_publish",
"input": {
"uri": "wrap://ipfs/QmakWH6aPYDjoq1XhnRJwE7Kgq7uyBDjX19WXCEzM1cyjX",
"config": {
"domainName": "animals.eth",
"ports": {
"ethereum": 8545
}
}
},
"result": "wrap://ens/animals.eth"
}
]
Loading