The @gardenfi/core
package serves as an abstraction layer over the @catalogfi/wallets
(contains different kind of bitcoin and evm wallets) and @gardenfi/orderbook
packages. It provides a simple interface to perform atomic swaps.
npm install `@gardenfi/core`
For more information regarding using the library in different environments see setup.
- Creating an atomic swap: (should create an order with valid parameters)
- Interacting with created orders: (should initiate and redeem)
No extra setup is required as both cjs
and esm
modules are supported.
Following cases only cover vite and webpack setups. For other bundlers, please refer to their respective documentation on how to add wasm and polyfills support.
Install the vite plugins:
npm install vite-plugin-wasm vite-plugin-top-level-await vite-plugin-node-polyfills --save-dev
and update your vite.config.ts
as follows:
import { defineConfig } from "vite";
import wasm from "vite-plugin-wasm";
import { nodePolyfills } from "vite-plugin-node-polyfills";
import topLevelAwait from "vite-plugin-top-level-await";
export default defineConfig({
plugins: [
nodePolyfills(),
wasm(),
topLevelAwait(),
//other plugins
],
//other settings
});
If you're using webpack with a framework like next, then in your webpack config, (if you're using NextJS, this can be found in next.config.js
) add support for wasm as shown below:
/** @type {import('next').NextConfig} */
const nextConfig = {
//other nextConfig options
webpack: function (config, options) {
//other webpack config options
config.experiments = {
...config.experiments,
asyncWebAssembly: true,
};
return config;
},
};
module.exports = nextConfig;