Skip to content
This repository was archived by the owner on Mar 11, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
576802d
chore: lazy load wasm
owonwo May 12, 2025
756af55
chore: disabled cjs bundle in favour of esm and fixed issue with webp…
owonwo May 15, 2025
8ec627a
chore: remove unnecesary code
owonwo May 15, 2025
1033b0f
chore: formatted files
owonwo May 15, 2025
348611a
Merge branch 'main' of github.com:polytope-labs/hyperbridge-sdk into …
owonwo May 15, 2025
1a5eac1
chore: release candidate 2
owonwo May 15, 2025
36998bb
chore: add wasm file to source code
owonwo May 15, 2025
7093b68
chore: updated missing timestamp normalization for timeout
owonwo May 15, 2025
90f6943
chore: bump sdk version
owonwo May 15, 2025
f3d064e
fix: unable to resolve wasm module in Node environment
owonwo May 20, 2025
483e5b1
chore: reset root package name
owonwo May 20, 2025
a046e27
Merge branch 'main' of github.com:polytope-labs/hyperbridge-sdk into …
owonwo May 27, 2025
679dc53
chore: split sdk bundles for web and node
owonwo May 27, 2025
1400f8f
chore: added vite plugin for load wasm file
owonwo May 27, 2025
d82fe6a
chore(sdk): formatted file
owonwo May 27, 2025
1e64d68
chore: remove console.log statment
owonwo May 27, 2025
1727789
chore: make ckb-mmr-wasm a seperate package
owonwo May 28, 2025
45665e5
chore: confirmed to work with zero configuration for webpack, vitest …
owonwo May 28, 2025
c26cc3b
doc(sdk): updated installed Readme to include vite plugin
owonwo May 28, 2025
2574415
chore: updated vitest due to dependbot warning
owonwo May 28, 2025
66164fc
fix: build error
owonwo May 28, 2025
03875f4
fix(sdk): type export error
owonwo May 28, 2025
03d762a
fix(sdk): filler test failing due to type resolution
owonwo May 28, 2025
ba4b062
fix(sdk): failing test case
owonwo May 28, 2025
912183f
chore: skip failing GNOSIS transfer transaction test
owonwo Jun 4, 2025
e2e679b
test(request): skip failing test related GNOSIS
owonwo Jun 4, 2025
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 packages/filler/src/tests/sdk-imports.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { __test } from 'hyperbridge-sdk';

it("should load test function and invoke without failure", async () => {
expect(await __test()).toMatchInlineSnapshot(`"{"root":"0x85835c4d5287fe023073eb733f4e4103935d61b4397f0f9d0fe627d434757fa5","proof":["0x894376e04f932deadc9ab212ac514f37b41e670be2f8002babde1faf20935461","0xf3ace1896f86f91627cc1c09eeaba2cd76d82a75be6f09b94c861524fa5e5289","0x0ffa0900c838d17341df2d00fa4832755de619e646137844700668ad544c8aae","0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470","0x9c6b2c1b0d0b25a008e6c882cc7b415f309965c72ad2b944ac0931048ca31cd5","0xfadbd3c7f79fa2bdc4f24857709cd4a4e870623dc9e9abcdfd6e448033e35212"],"mmr_size":236,"leaf_positions":[232],"keccak_hash_calldata":"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"}"`);
})
2 changes: 1 addition & 1 deletion packages/sdk/biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"files": {
"ignoreUnknown": false,
"ignore": ["./dist"]
"ignore": ["./dist/*", "./src/utils/ckb-mmr-wasm/*"]
},
"formatter": {
"enabled": false
Expand Down
30 changes: 20 additions & 10 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
{
"name": "hyperbridge-sdk",
"version": "1.1.7-rc.1",
"version": "1.1.7-rc.3",
"description": "The hyperclient SDK provides utilities for querying proofs and statuses for cross-chain requests from HyperBridge.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"type": "module",
"types": "./dist/node/index.d.ts",
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.cjs"
"browser": "./dist/browser/index.js",
"import": "./dist/node/index.js"
},
"./plugins/vite": {
"import": "./plugins/vite.js",
"types": "./plugins/vite.d.ts"
}
},
"files": [
"dist"
"dist",
"plugins"
],
"keywords": [
"hyperbridge",
Expand All @@ -36,7 +40,9 @@
"license": "ISC",
"author": "Polytope Labs",
"scripts": {
"build": "tsup",
"build": "pnpm run build:browser && pnpm run build:node",
"build:node": "tsup --config tsup-node.config.ts",
"build:browser": "tsup --config tsup-browser.config.ts",
"prepublishOnly": "npm run build",
"test": "npm run test:concurrent && npm run test:sequence",
"test:file": "vitest --watch=false --maxConcurrency=1",
Expand All @@ -54,13 +60,14 @@
"@polkadot/types": "14.0.1",
"@polkadot/util": "13.3.1",
"@polkadot/util-crypto": "13.3.1",
"consola": "^3.4.2",
"@types/lodash-es": "^4.17.12",
"consola": "^3.4.2",
"graphql": "^16.10.0",
"graphql-request": "^7.1.2",
"lodash-es": "^4.17.15",
"rpc-websocket-client": "^1.1.4",
"scale-ts": "^1.6.1",
"lodash-es": "^4.17.15",
"std-env": "^3.9.0",
"ts-pattern": "^5.6.2",
"viem": "^2.23.5"
},
Expand All @@ -73,11 +80,14 @@
"dotenv": "^16.4.7",
"jsdom": "^26.0.0",
"log-timestamp": "^0.3.0",
"typescript": "^5.7.3",
"tsup": "^8.4.0",
"typescript": "^5.7.3",
"vite-tsconfig-paths": "^5.1.4",
"vitest": "^3.0.7"
},
"peerDependencies": {
"vite": "^5.0.0 || ^6.0.0"
},
"publishConfig": {
"access": "public"
},
Expand Down
11 changes: 11 additions & 0 deletions packages/sdk/plugins/vite.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { Plugin } from "vite"

/**
* A Vite plugin that copies the WebAssembly file from hyperbridge-sdk to the Vite cache directory.
* This ensures the WASM file is available for browser imports when using Vite.
*
* @returns {Plugin} A Vite plugin
*/
export function copyWasm(): Plugin

export default copyWasm
55 changes: 55 additions & 0 deletions packages/sdk/plugins/vite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import path from "node:path"
import { copyFile } from "node:fs/promises"
import { colorize } from "consola/utils"

const logMessage = (message) => {
const time = new Date().toLocaleTimeString([], {
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
hour12: true,
})

const timestamp = colorize("dim", time)
const tag = colorize("bold", colorize("magenta", "[hyperbridge]"))

return console.log(timestamp, tag, message)
}

/**
*
* @returns {Plugin}
*/
export const copyWasm = () => {
return {
name: "hyperbridge-copy-wasm-plugin",
buildStart: async function makeCopy(ctx) {
const is_dev_mode = Object.keys(ctx).length === 0

if (!is_dev_mode) return

// Get path to the consuming project's node_modules
const projectNodeModules = path.resolve(process.cwd(), "node_modules")

// Find the hyperbridge-sdk package in node_modules
const source = path.resolve(projectNodeModules, "hyperbridge-sdk/dist/browser/web_bg.wasm")

// Destination in the Vite cache directory
const destDir = path.resolve(projectNodeModules, ".vite/deps")
const dest = path.resolve(destDir, "web_bg.wasm")

// Wait for .vite folder to exist
setTimeout(async () => {
try {
logMessage("📦 Copying wasm dependency")
await copyFile(source, dest)
logMessage("✅ Copy complete")
} catch (error) {
logMessage(`❌ Error copying wasm file: ${error.message}`)
}
}, 2000)
},
}
}

export default copyWasm
Loading