Warp bundlers repository aims to provide sample projects using Warp SDK within diferent web and server bundles. Due to various implementation of bundlers, each of these projects need to meet specific requirements which are described in this readme.
If you encounter any issues while using Warp SDK in a specific bundler (due to upgraded version etc.), please create an issue in the repository.
You can find helper scripts in the root package.json
file, you can use either yarn
or npm
. For each of the project we are testing deploying the contract, writing interaction and reading the state.
- Install dependencies
yarn install:[PROJECT_NAME]
- Start development server
yarn start:[PROJECT_NAME]
- Build for production
yarn build:[PROJECT_NAME]
- Install dependencies
yarn install:node
- Build typescript files and run all server scripts (
.mjs
,.js
,.ts
, usingts-node
instead of regularnode
script)
yarn run:node
Web bundlers - Next - Parcel - Rollup - Unpkg - Vite - Webpack 4 - Webpack 5
Server - Node
Directory: Refer to this directory to see the bundler configuration.
Usage:
import { defaultCacheOptions, WarpFactory } from 'warp-contracts';
const warp = WarpFactory.forMainnet();
Additional configuration:
In order for production deployment to work properly, it is needed to set swcMinify
property to false
. Please refer to this github issue to see the reason for applying this change.
const nextConfig = {
swcMinify: false,
};
Directory: Refer to this directory to see the bundler configuration.
Usage:
import { defaultCacheOptions, WarpFactory } from 'warp-contracts';
const warp = WarpFactory.forMainnet();
Additional configuration: Not required.
Directory: Refer to this directory to see the bundler configuration.
Usage:
import { defaultCacheOptions, WarpFactory } from 'warp-contracts';
const warp = WarpFactory.forMainnet();
Additional configuration: Not required.
Directory: Refer to this directory to see the bundler configuration. You can use either full or minfied version of the Warp SDK, check out this section to view possible options.
Usage:
Insert script
tag in your index.html
file:
<script src="https://unpkg.com/[email protected]/bundles/web.iife.bundle.min.js"></script>
const sdk = warp.WarpFactory.forMainnet();
Additional configuration:
- In order for Typescript project to work properly, you need to extend
Window
type bywarp
. You have few options to choose from, eg.:
const warp = window['warp'];
or
const warp = (<any>window).warp;
- Remember to set
isolatedModules
property tofalse
incompilerOptions
in yourtsconfig.json
file.
Directory: Refer to this directory to see the bundler configuration.
Usage:
import { defaultCacheOptions, WarpFactory } from 'warp-contracts';
const warp = WarpFactory.forMainnet();
Additional configuration: Not required.
Directory: Refer to this directory to see the bundler configuration.
Usage:
import { WarpFactory, defaultCacheOptions } from 'warp-contracts';
const warp = WarpFactory.forMainnet();
Additional configuration:
- In order for Typescript project to work properly, you need to set
strict
property tofalse
in thecompilerOptions
in yourtsconfig.json
file. You can also add//@ts-ignore
abovewarp-contracts
import.
Directory: Refer to this directory to see the bundler configuration.
Usage:
import { WarpFactory, defaultCacheOptions } from 'warp-contracts';
const warp = WarpFactory.forMainnet();
Additional configuration:
- In order for Typescript project to work properly, you need to set
strict
property tofalse
andmoduleResolution
tonodenext
in thecompilerOptions
in yourtsconfig.json
file. You can also add//@ts-ignore
abovewarp-contracts
import.
For server side we are testing
CommonJS
version in a.js
fileECMAScript
version in a.mjs
fileTypescript
- in a
.js
file compiled withtsc
command - directly in a
.ts
file executed withts-node
exection machine
- in a