Project Setup
You're reading Part One of the Create Wraps tutorial, where we learn everything you need to know to productively develop Polywrap wraps.
Welcome to Part One of the Create Wraps tutorial. We will build a new Polywrap wrap called "Oracle Wrap". Oracle Wrap is capable of both obscuring and illuminating knowledge using hashing and generative AI.
Please read the Introduction if you haven't done so already. Otherwise, let's dive right in!
Create the Project
We will generate our project scaffolding using the Polywrap CLI. The create
command of the Polywrap CLI uses the syntax polywrap create <project type> <language> <name>
to download a project template. This tutorial is about building Wasm wraps, so let's create a wasm
project and name it oracle-wrap
- Rust
- Go
- TypeScript
- AssemblyScript
polywrap create wasm rust oracle-wrap
polywrap create wasm golang oracle-wrap
polywrap create wasm typescript oracle-wrap
polywrap create wasm assemblyscript oracle-wrap
After running this command, you'll see a new folder appear with the project name.
Project Contents
Let's take a look at the contents of the project we just created. Then, in the next section, we'll review the project manifest file and learn how to configure it.
- Rust
- Go
- TypeScript
- AssemblyScript
project/
├── polywrap.yaml # Project manifest File
├── polywrap.graphql # Wrap Schema
├── src/
│ └── lib.rs # Entry point; exports module defined in schema
├── tests/ # Integration tests
├── Cargo.toml # Dependency management
├── package.json # Build scripts
└── tsconfig.json # TypeScript configuration (for integration tests)
polywrap.yaml
The polywrap.yaml
project manifest is a high-level configuration file describing a Polywrap project.
polywrap.graphql
Each wrap project has a Wrap Schema. The schema defines the wrap's interface, including dependencies, methods, and custom types. Polywrap uses the schema to generate the wrap's serialization bindings and validate the wrap's implementation. The schema is compiled to a wrap.info
ABI file at build time and stored in the wrap package. In this tutorial, we'll learn how to write a Wrap Schema. It's easy!
src/lib.rs
The entry point file differs by language, but in all cases it exports the wrap module implementation.
tests/
The tests directory contains integration tests for the wrap. Integration tests are performed using a Polywrap Client to invoke the wrap, just as a developer would do when using your wrap in their application. Without a client, you wouldn't be able to test the parts of your code that invoke other wraps or plugins.
The tests directory contains a `types` folder with configuration files used to generate bindings for the tests in the client language. Depending on your project's language, the test types will be generated in TypeScript or Rust. The bindings are based on your wrap's schema and allow you to call methods on your wrap with an experience similar to the native programming language of the tests (i.e. TypeScript or Rust). The bindings are optional, but we recommend using them.
package.json
We include a package.json
file with pre-written build scripts and developer dependencies for testing, even if your wrap is not written in TypeScript or AssemblyScript.
If you're building a Rust wrap, the package.json
file is used only for build scripts and is not required for testing. Feel free to delete it or use it only as a reference.
We understand that not every user wants to install NodeJS to build with Polywrap. Don't worry! In Part Two of the tutorial, we will learn how to write language-agnostic tests without any JavaScript dependencies.
tsconfig.json
Used to configure TypeScript for integration tests.
project/
├── polywrap.yaml # Project manifest File
├── polywrap.graphql # Wrap Schema
├── module/
│ ├── module.go # Entry point; exports module defined in schema
│ └── __tests__/ # Integration tests
├── build-staging/ # Required boilerplate; don't modify
├── go.mod # Dependency management
├── package.json # Build scripts
└── tsconfig.json # TypeScript configuration (for integration tests)
polywrap.yaml
The polywrap.yaml
project manifest is a high-level configuration file describing a Polywrap project.
polywrap.graphql
Each wrap project has a Wrap Schema. The schema defines the wrap's interface, including dependencies, methods, and custom types. Polywrap uses the schema to generate the wrap's serialization bindings and validate the wrap's implementation. The schema is compiled to a wrap.info
ABI file at build time and stored in the wrap package. In this tutorial, we'll learn how to write a Wrap Schema. It's easy!
module/module.go
The entry point file differs by language, but in all cases it exports the wrap module implementation.
module/__tests__/
The tests directory contains integration tests for the wrap. Integration tests are performed using a Polywrap Client to invoke the wrap, just as a developer would do when using your wrap in their application. Without a client, you wouldn't be able to test the parts of your code that invoke other wraps or plugins.
The tests directory contains a `types` folder with configuration files used to generate bindings for the tests in the client language. Depending on your project's language, the test types will be generated in TypeScript or Rust. The bindings are based on your wrap's schema and allow you to call methods on your wrap with an experience similar to the native programming language of the tests (i.e. TypeScript or Rust). The bindings are optional, but we recommend using them.
package.json
We include a package.json
file with pre-written build scripts and developer dependencies for testing, even if your wrap is not written in TypeScript or AssemblyScript.
If you're building a Rust wrap, the package.json
file is used only for build scripts and is not required for testing. Feel free to delete it or use it only as a reference.
We understand that not every user wants to install NodeJS to build with Polywrap. Don't worry! In Part Two of the tutorial, we will learn how to write language-agnostic tests without any JavaScript dependencies.
tsconfig.json
Used to configure TypeScript for integration tests.
build-staging/
Required boilerplate; don't modify.
project/
├── polywrap.yaml # Project manifest File
├── polywrap.graphql # Wrap Schema
├── src/
│ ├── index.ts # Entry point; exports module defined in schema
│ └── __tests__/ # Integration tests
├── package.json # Dependency management and build scripts
├── rollup.config.mjs # Bundler configuration
├── shims.js # Shims for a native TypeScript experience
└── tsconfig.json # TypeScript configuration
polywrap.yaml
The polywrap.yaml
project manifest is a high-level configuration file describing a Polywrap project.
polywrap.graphql
Each wrap project has a Wrap Schema. The schema defines the wrap's interface, including dependencies, methods, and custom types. Polywrap uses the schema to generate the wrap's serialization bindings and validate the wrap's implementation. The schema is compiled to a wrap.info
ABI file at build time and stored in the wrap package. In this tutorial, we'll learn how to write a Wrap Schema. It's easy!
src/index.ts
The entry point file differs by language, but in all cases it exports the wrap module implementation.
src/__tests__/
The tests directory contains integration tests for the wrap. Integration tests are performed using a Polywrap Client to invoke the wrap, just as a developer would do when using your wrap in their application. Without a client, you wouldn't be able to test the parts of your code that invoke other wraps or plugins.
The tests directory contains a `types` folder with configuration files used to generate bindings for the tests in the client language. Depending on your project's language, the test types will be generated in TypeScript or Rust. The bindings are based on your wrap's schema and allow you to call methods on your wrap with an experience similar to the native programming language of the tests (i.e. TypeScript or Rust). The bindings are optional, but we recommend using them.
package.json
We include a package.json
file with pre-written build scripts and developer dependencies for testing, even if your wrap is not written in TypeScript or AssemblyScript.
If you're building a Rust wrap, the package.json
file is used only for build scripts and is not required for testing. Feel free to delete it or use it only as a reference.
We understand that not every user wants to install NodeJS to build with Polywrap. Don't worry! In Part Two of the tutorial, we will learn how to write language-agnostic tests without any JavaScript dependencies.
tsconfig.json
Used to configure TypeScript for integration tests.
rollup.config.mjs
Used to configure bundling for the wrap.
shims.js
Used to provide a more native TypeScript experience.
project/
├── polywrap.yaml # Project manifest File
├── polywrap.graphql # Wrap Schema
├── src/
│ ├── index.ts # Entry point; exports module defined in schema
│ └── __tests__/ # Integration tests
├── package.json # Dependency management and build scripts
├── tsconfig.json # TypeScript configuration (for integration tests)
└── tsconfig.build.json # AssemblyScript configuration (for build)
polywrap.yaml
The polywrap.yaml
project manifest is a high-level configuration file describing a Polywrap project.
polywrap.graphql
Each wrap project has a Wrap Schema. The schema defines the wrap's interface, including dependencies, methods, and custom types. Polywrap uses the schema to generate the wrap's serialization bindings and validate the wrap's implementation. The schema is compiled to a wrap.info
ABI file at build time and stored in the wrap package. In this tutorial, we'll learn how to write a Wrap Schema. It's easy!
src/index.ts
The entry point file differs by language, but in all cases it exports the wrap module implementation.
src/__tests__/
The tests directory contains integration tests for the wrap. Integration tests are performed using a Polywrap Client to invoke the wrap, just as a developer would do when using your wrap in their application. Without a client, you wouldn't be able to test the parts of your code that invoke other wraps or plugins.
The tests directory contains a `types` folder with configuration files used to generate bindings for the tests in the client language. Depending on your project's language, the test types will be generated in TypeScript or Rust. The bindings are based on your wrap's schema and allow you to call methods on your wrap with an experience similar to the native programming language of the tests (i.e. TypeScript or Rust). The bindings are optional, but we recommend using them.
package.json
We include a package.json
file with pre-written build scripts and developer dependencies for testing, even if your wrap is not written in TypeScript or AssemblyScript.
If you're building a Rust wrap, the package.json
file is used only for build scripts and is not required for testing. Feel free to delete it or use it only as a reference.
We understand that not every user wants to install NodeJS to build with Polywrap. Don't worry! In Part Two of the tutorial, we will learn how to write language-agnostic tests without any JavaScript dependencies.
tsconfig.json
Used to configure TypeScript for integration tests.
tsconfig.build.json
Used to configure AssemblyScript for wrap development.
Next Steps
In the next section we will set up the Project Manifest file, which contains metadata the Polywrap CLI needs to build your wrap.