Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • hive/wax
1 result
Show changes
Commits on Source (42)
Showing
with 206 additions and 58 deletions
......@@ -224,6 +224,7 @@ storage_root-node
/ts/yarn.lock
/examples/ts/package-lock.json
/examples/ts/yarn.lock
/examples/ts/**/test-results
# Ignore lock files in examples
/examples/ts/**/pnpm-lock.yaml
......
......@@ -6,7 +6,7 @@ stages:
include:
- project: 'hive/common-ci-configuration'
ref: 12db226cfde2df929bb8bcb0c7c51d04c8900d32
ref: 40451cfbe8c2995c66b2d4150dbb3c4d11fd8590
file:
- '/templates/npm_projects.gitlab-ci.yml'
- '/templates/wasm_build.gitlab-ci.yml'
......@@ -78,11 +78,9 @@ wax_wasm_proto_tsc_generation:
- "${DIST_DIR}/*.tgz" # Built package
- "${CI_PROJECT_DIR}/ts/wasm/lib/proto" # For documentation generator
- "${CI_PROJECT_DIR}/ts/wasm/lib/build_wasm" # For documentation generator
- "${DIST_DIR}/lib/build_wasm/wax.common.js" # For base WASM tests
- "${DIST_DIR}/lib/build_wasm/types.ts" # For base WASM tests
- "${CI_PROJECT_DIR}/ts/wasm/build_wasm/wax.node.js" # For documentation generator
- "${DIST_DIR}/lib/proto" # For protobuf pattern tests
- "${DIST_DIR}/lib" # For Node.js tests
- "${DIST_DIR}/bundle/index-full.js" # For web tests
tags:
- public-runner-docker
......
......@@ -5,6 +5,7 @@
#include <fc/optional.hpp>
#include <fc/static_variant.hpp>
#include <fc/crypto/hex.hpp>
#include <string>
......
......@@ -2,9 +2,11 @@
#include "core/types.hpp"
#include "core/utils.hpp"
#include "fc/crypto/elliptic.hpp"
#include <fc/reflect/reflect.hpp>
#include <fc/io/json.hpp>
#include <fc/crypto/elliptic.hpp>
#include <fc/crypto/hex.hpp>
#include <boost/lexical_cast.hpp>
......
......@@ -20,6 +20,8 @@
#include <fc/bitutil.hpp>
#include <fc/container/flat.hpp>
#include <fc/crypto/hex.hpp>
#include <algorithm>
namespace cpp {
......
......@@ -22,7 +22,10 @@ const configFor = (name: string): ConstructorParameters<typeof Parcel>[0] => ({
const port = 8000;
const server = createServer({
root: path.resolve(__dirname, 'dist')
root: path.resolve(__dirname, 'dist'),
logFn(req, res) {
console.log(req.method, req.url, res.statusCode);
},
});
server.listen(port);
......
{
"name": "examples-html",
"packageManager": "pnpm@9.1.1+sha256.9551e803dcb7a1839fdf5416153a844060c7bce013218ce823410532504ac10b",
"packageManager": "pnpm@9.15.4+sha512.b2dc20e2fc72b3e18848459b37359a32064663e5627a51e4c74b2c29dd8e8e0491483c3abb40789cfd578bf362fb6ba8261b05f0387d76792ed6e23ea3b1b6a0",
"scripts": {
"pretest": "playwright install",
"test": "pnpx tsx index.ts"
"pretest": "playwright install chromium",
"test": "rm -rf ./.parcel-cache ./dist && pnpx tsx index.ts"
},
"devDependencies": {
"@parcel/config-default": "^2.12.0",
"@parcel/core": "^2.12.0",
"@playwright/test": "^1.39.0",
"@playwright/test": "^1.49.1",
"@types/http-server": "^0.12.4",
"@types/node": "^20.10.6",
"buffer": "^6.0.3",
"crypto-browserify": "^3.12.0",
"http-server": "^14.1.1",
"path-browserify": "^1.0.1",
"playwright": "^1.39.0",
"process": "^0.11.10",
"stream-browserify": "^3.0.0",
"playwright": "^1.49.1",
"tsx": "^4.7.0",
"typescript": "5.2.2"
"typescript": "5.7.3"
},
"dependencies": {
"@hiveio/beekeeper": "1.27.6-rc3-stable.240916231926",
"@hiveio/beekeeper": "1.27.8-stable.250129121514",
"@hiveio/wax": "file:../../../ts"
},
"type": "module",
......
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
# nextjs-app
## Getting Started
Created by command: `npx create-next-app@latest nextjs-app`
First, run the development server:
```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file.
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`.
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.
## Learn More
To learn more about Next.js, take a look at the following resources:
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
## Deploy on Vercel
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
[pages/index.tsx](pages/index.tsx) file was modified
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
reactStrictMode: true
};
export default nextConfig;
......@@ -4,7 +4,7 @@
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"build": "rm -rf ./.next && next build",
"start": "next start",
"lint": "next lint"
},
......
......@@ -6,7 +6,7 @@
"scripts": {
"build": "tsc",
"start": "node dist/index.js",
"test": "npm run build && npm run start"
"test": "rm -rf ./dist && npm run build && npm run start"
},
"dependencies": {
"@hiveio/wax": "file:../../../ts"
......
# Nuxt dev/build outputs
.output
.data
.nuxt
.nitro
.cache
dist
# Node dependencies
node_modules
# Logs
logs
*.log
# Misc
.DS_Store
.fleet
.idea
# Local env files
.env
.env.*
!.env.example
# https://gitlab.syncad.com/hive group specification, offering aggregated package view: https://gitlab.syncad.com/groups/hive/-/packages
@hiveio:registry=https://gitlab.syncad.com/api/v4/groups/136/-/packages/npm/
# Nuxt (Vite)
[app.vue](app.vue) file was modified.
Important note!:
__**When importing Wax in Vite, remember to import dedicated Vite bundle everywhere in your project: `@hiveio/wax/vite`**__
Also remember that you have to asynchronously import Wax in Nuxt (e.g. using onBeforeMount hook or store)
## WASM-related Vite issues
Internal Note:
Vite currently does not fully support .WASM files as described [here](https://vite.dev/guide/features#webassembly), so we had to create some workarounds
* https://github.com/rustwasm/wasm-pack/issues/1106#issuecomment-2237247752
* https://stackoverflow.com/a/79204138
* https://github.com/vitejs/vite/issues/10761#issuecomment-1334844871
* https://vite.dev/guide/assets#explicit-url-imports
* https://www.npmjs.com/package/vite-plugin-wasm
import { expect, test } from '@playwright/test';
const waitForServerReady = async (url: string, interval: number = 1000, attempts: number = 10): Promise<void> => {
console.log(`Awaiting a server: ${url}...`);
for (let count = 0; count < attempts; ++count) {
try {
console.log(`Trying to connect ${count}/${attempts})`);
const response = await fetch(url, {
method: "GET",
signal: AbortSignal.timeout(interval)
});
if (response.ok && response.status === 200) {
console.log(`Connected successfully (${count}/${attempts}). Exiting.`);
return;
}
}
catch (error) {
if (typeof error !== "object" || !(error instanceof Error))
console.log(`Caught an UNKNOWN error (${JSON.stringify(error)})`);
else
if (error.name === "TimeoutError")
console.log(`Caught a TIMEOUT error (${JSON.stringify(error)})`);
else
if (error.name === "AbortError")
console.log(`Caught an ABORT error (${JSON.stringify(error)})`);
}
console.log(`Waiting for ${interval} ms...)`);
await new Promise(resolve => { setTimeout(resolve, interval); });
}
console.log(`Still down - bailing out.`);
};
test.describe('Proper WASM Wax loading on playwright ', () => {
test.beforeEach(async ({ page }) => {
/// use >> marker for each texts printed in the browser context
page.on('console', msg => {
console.log('>>', msg.type(), msg.text());
});
await waitForServerReady("http://localhost:5173");
await page.goto("http://localhost:5173", { waitUntil: "load" });
});
test('WASM should be properly loaded during development', async ({ page }) => {
// Wait for wax to be loaded
await page.waitForFunction(() => typeof (window as any).waxLoaded !== "undefined");
const result = await page.evaluate(async() => {
return (window as any).waxLoaded; // This value is set by this app in App.vue after successfull wax initialization
});
// Wax should be loaded
expect(result).toBe(true);
});
});
<script setup>
import { createWaxFoundation } from "@hiveio/wax/vite";
import { onBeforeMount } from 'vue';
const version = ref('');
onBeforeMount(async () => {
try {
const wax = await createWaxFoundation();
version.value = wax.getVersion();
window.waxLoaded = true;
} catch (error) {
console.error(error);
window.waxLoaded = false;
}
});
</script>
<template>
<div>
{{ version }}
</div>
</template>
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
compatibilityDate: '2024-11-01',
debug: false
})
{
"name": "nuxt-app",
"private": true,
"type": "module",
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev --host 0.0.0.0 --port 5173",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare",
"test": "rm -rf ./.nuxt ./.output ./node_modules/.cache && unset CI && DEBUG=pw:webserver playwright test --workers 1 --max-failures 1 --project=wax_nuxt_vite_testsuite"
},
"dependencies": {
"@hiveio/wax": "file:../../../ts",
"@playwright/test": "1.49.1",
"nuxt": "^3.15.3",
"playwright": "1.49.1",
"vue": "latest",
"vue-router": "latest"
}
}
// This is a workaround for https://github.com/microsoft/playwright/issues/18282#issuecomment-1612266345
import { defineConfig } from '@playwright/test';
export default defineConfig({
projects: [
{
name: "wax_nuxt_vite_testsuite",
testDir: "./__tests__"
}
],
// Run your local dev server before starting the tests
webServer: {
command: 'npm run dev'
}
});
{
// https://nuxt.com/docs/guide/concepts/typescript
"extends": "./.nuxt/tsconfig.json"
}