diff --git a/package-lock.json b/package-lock.json
index 9a7c1e5d5..eacff5029 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1351,21 +1351,6 @@
"ws": "*"
}
},
- "node_modules/@cardano-ogmios/client/node_modules/utf-8-validate": {
- "version": "5.0.10",
- "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.10.tgz",
- "integrity": "sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ==",
- "hasInstallScript": true,
- "license": "MIT",
- "optional": true,
- "peer": true,
- "dependencies": {
- "node-gyp-build": "^4.3.0"
- },
- "engines": {
- "node": ">=6.14.2"
- }
- },
"node_modules/@cardano-ogmios/client/node_modules/ws": {
"version": "7.5.10",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz",
@@ -19133,6 +19118,7 @@
"version": "3.9.0",
"resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz",
"integrity": "sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==",
+ "dev": true,
"funding": [
{
"type": "github",
@@ -23486,6 +23472,7 @@
"version": "2.8.9",
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz",
"integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==",
+ "dev": true,
"license": "ISC"
},
"node_modules/html-escaper": {
@@ -25365,6 +25352,7 @@
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz",
"integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==",
+ "dev": true,
"license": "MIT"
},
"node_modules/json-schema-traverse": {
@@ -27078,6 +27066,7 @@
"version": "4.2.8",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-4.2.8.tgz",
"integrity": "sha512-fNzuVyifolSLFL4NzpF+wEF4qrgqaaKX0haXPQEdQ7NKAN+WecoKMHV09YcuL/DHxrUsYQOK3MiuDf7Ip2OXfQ==",
+ "dev": true,
"license": "ISC",
"engines": {
"node": ">=8"
@@ -27581,6 +27570,7 @@
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz",
"integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==",
+ "dev": true,
"license": "BSD-2-Clause",
"dependencies": {
"hosted-git-info": "^2.1.4",
@@ -27593,6 +27583,7 @@
"version": "5.7.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz",
"integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==",
+ "dev": true,
"license": "ISC",
"bin": {
"semver": "bin/semver"
@@ -33413,6 +33404,7 @@
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.2.0.tgz",
"integrity": "sha512-kN9dJbvnySHULIluDHy32WHRUu3Og7B9sbY7tsFLctQkIqnMh3hErYgdMjTYuqmcXX+lK5T1lnUt3G7zNswmZA==",
+ "dev": true,
"license": "Apache-2.0",
"dependencies": {
"spdx-expression-parse": "^3.0.0",
@@ -33423,12 +33415,14 @@
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.5.0.tgz",
"integrity": "sha512-PiU42r+xO4UbUS1buo3LPJkjlO7430Xn5SVAhdpzzsPHsjbYVflnnFdATgabnLude+Cqu25p6N+g2lw/PFsa4w==",
+ "dev": true,
"license": "CC-BY-3.0"
},
"node_modules/spdx-expression-parse": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz",
"integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==",
+ "dev": true,
"license": "MIT",
"dependencies": {
"spdx-exceptions": "^2.1.0",
@@ -33439,6 +33433,7 @@
"version": "3.0.22",
"resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.22.tgz",
"integrity": "sha512-4PRT4nh1EImPbt2jASOKHX7PB7I+e4IWNLvkKFDxNhJlfjbYlleYQh285Z/3mPTHSAK/AvdMmw5BNNuYH8ShgQ==",
+ "dev": true,
"license": "CC0-1.0"
},
"node_modules/speed-limiter": {
@@ -34092,21 +34087,6 @@
}
}
},
- "node_modules/svelte-check/node_modules/picomatch": {
- "version": "4.0.3",
- "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz",
- "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
- "dev": true,
- "license": "MIT",
- "optional": true,
- "peer": true,
- "engines": {
- "node": ">=12"
- },
- "funding": {
- "url": "https://github.com/sponsors/jonschlinkert"
- }
- },
"node_modules/svelte-check/node_modules/readdirp": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz",
@@ -36027,6 +36007,7 @@
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz",
"integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==",
+ "dev": true,
"license": "Apache-2.0",
"dependencies": {
"spdx-correct": "^3.0.0",
@@ -36211,18 +36192,6 @@
}
}
},
- "node_modules/vite-plugin-top-level-await/node_modules/@swc/helpers": {
- "version": "0.5.17",
- "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.17.tgz",
- "integrity": "sha512-5IKx/Y13RsYd+sauPb2x+U/xZikHjolzfuDgTAl/Tdf3Q8rslRvC19NKDLgAJQ6wsqADk10ntlv08nPFw/gO/A==",
- "dev": true,
- "license": "Apache-2.0",
- "optional": true,
- "peer": true,
- "dependencies": {
- "tslib": "^2.8.0"
- }
- },
"node_modules/vite-plugin-top-level-await/node_modules/uuid": {
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-10.0.0.tgz",
@@ -37156,6 +37125,7 @@
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-4.0.2.tgz",
"integrity": "sha512-7KxauUdBmSdWnmpaGFg+ppNjKF8uNLry8LyzjauQDOVONfFLNKrKvQOxZ/VuTIcS/gge/YNahf5RIIQWTSarlg==",
+ "dev": true,
"license": "ISC",
"dependencies": {
"imurmurhash": "^0.1.4",
@@ -37169,6 +37139,7 @@
"version": "3.0.7",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz",
"integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==",
+ "dev": true,
"license": "ISC"
},
"node_modules/ws": {
@@ -37418,7 +37389,7 @@
},
"packages/bitcoin": {
"name": "@meshsdk/bitcoin",
- "version": "1.9.0-beta.79",
+ "version": "1.9.0-beta.80",
"dependencies": {
"@bitcoin-js/tiny-secp256k1-asmjs": "^2.2.3",
"bip174": "^3.0.0-rc.1",
@@ -37474,18 +37445,6 @@
}
}
},
- "packages/bitcoin/node_modules/@swc/helpers": {
- "version": "0.5.17",
- "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.17.tgz",
- "integrity": "sha512-5IKx/Y13RsYd+sauPb2x+U/xZikHjolzfuDgTAl/Tdf3Q8rslRvC19NKDLgAJQ6wsqADk10ntlv08nPFw/gO/A==",
- "dev": true,
- "license": "Apache-2.0",
- "optional": true,
- "peer": true,
- "dependencies": {
- "tslib": "^2.8.0"
- }
- },
"packages/configs": {
"name": "@meshsdk/configs",
"version": "0.0.0",
@@ -37705,7 +37664,7 @@
},
"packages/mesh-common": {
"name": "@meshsdk/common",
- "version": "1.9.0-beta.79",
+ "version": "1.9.0-beta.80",
"license": "Apache-2.0",
"dependencies": {
"bech32": "^2.0.0",
@@ -37723,11 +37682,11 @@
},
"packages/mesh-contract": {
"name": "@meshsdk/contract",
- "version": "1.9.0-beta.79",
+ "version": "1.9.0-beta.80",
"license": "Apache-2.0",
"dependencies": {
- "@meshsdk/common": "1.9.0-beta.79",
- "@meshsdk/core": "1.9.0-beta.79"
+ "@meshsdk/common": "1.9.0-beta.80",
+ "@meshsdk/core": "1.9.0-beta.80"
},
"devDependencies": {
"@meshsdk/configs": "*",
@@ -37738,15 +37697,15 @@
},
"packages/mesh-core": {
"name": "@meshsdk/core",
- "version": "1.9.0-beta.79",
+ "version": "1.9.0-beta.80",
"license": "Apache-2.0",
"dependencies": {
- "@meshsdk/common": "1.9.0-beta.79",
- "@meshsdk/core-cst": "1.9.0-beta.79",
- "@meshsdk/provider": "1.9.0-beta.79",
- "@meshsdk/react": "1.9.0-beta.79",
- "@meshsdk/transaction": "1.9.0-beta.79",
- "@meshsdk/wallet": "1.9.0-beta.79"
+ "@meshsdk/common": "1.9.0-beta.80",
+ "@meshsdk/core-cst": "1.9.0-beta.80",
+ "@meshsdk/provider": "1.9.0-beta.80",
+ "@meshsdk/react": "1.9.0-beta.80",
+ "@meshsdk/transaction": "1.9.0-beta.80",
+ "@meshsdk/wallet": "1.9.0-beta.80"
},
"devDependencies": {
"@meshsdk/configs": "*",
@@ -37757,10 +37716,10 @@
},
"packages/mesh-core-csl": {
"name": "@meshsdk/core-csl",
- "version": "1.9.0-beta.79",
+ "version": "1.9.0-beta.80",
"license": "Apache-2.0",
"dependencies": {
- "@meshsdk/common": "1.9.0-beta.79",
+ "@meshsdk/common": "1.9.0-beta.80",
"@sidan-lab/whisky-js-browser": "^1.0.11",
"@sidan-lab/whisky-js-nodejs": "^1.0.11",
"@types/base32-encoding": "^1.0.2",
@@ -37770,7 +37729,7 @@
},
"devDependencies": {
"@meshsdk/configs": "*",
- "@meshsdk/provider": "1.9.0-beta.79",
+ "@meshsdk/provider": "1.9.0-beta.80",
"@types/json-bigint": "^1.0.4",
"eslint": "^8.57.0",
"ts-jest": "^29.1.4",
@@ -37780,7 +37739,7 @@
},
"packages/mesh-core-cst": {
"name": "@meshsdk/core-cst",
- "version": "1.9.0-beta.79",
+ "version": "1.9.0-beta.80",
"license": "Apache-2.0",
"dependencies": {
"@cardano-sdk/core": "^0.45.5",
@@ -37791,7 +37750,7 @@
"@harmoniclabs/pair": "^1.0.0",
"@harmoniclabs/plutus-data": "1.2.4",
"@harmoniclabs/uplc": "1.2.4",
- "@meshsdk/common": "1.9.0-beta.79",
+ "@meshsdk/common": "1.9.0-beta.80",
"@types/base32-encoding": "^1.0.2",
"base32-encoding": "^1.0.0",
"bech32": "^2.0.0",
@@ -37810,11 +37769,11 @@
},
"packages/mesh-hydra": {
"name": "@meshsdk/hydra",
- "version": "1.9.0-beta.79",
+ "version": "1.9.0-beta.80",
"dependencies": {
- "@meshsdk/common": "1.9.0-beta.79",
- "@meshsdk/core": "1.9.0-beta.79",
- "@meshsdk/core-cst": "1.9.0-beta.79",
+ "@meshsdk/common": "1.9.0-beta.80",
+ "@meshsdk/core": "1.9.0-beta.80",
+ "@meshsdk/core-cst": "1.9.0-beta.80",
"axios": "^1.7.2"
},
"devDependencies": {
@@ -37864,26 +37823,14 @@
}
}
},
- "packages/mesh-hydra/node_modules/@swc/helpers": {
- "version": "0.5.17",
- "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.17.tgz",
- "integrity": "sha512-5IKx/Y13RsYd+sauPb2x+U/xZikHjolzfuDgTAl/Tdf3Q8rslRvC19NKDLgAJQ6wsqADk10ntlv08nPFw/gO/A==",
- "dev": true,
- "license": "Apache-2.0",
- "optional": true,
- "peer": true,
- "dependencies": {
- "tslib": "^2.8.0"
- }
- },
"packages/mesh-provider": {
"name": "@meshsdk/provider",
- "version": "1.9.0-beta.79",
+ "version": "1.9.0-beta.80",
"license": "Apache-2.0",
"dependencies": {
- "@meshsdk/bitcoin": "1.9.0-beta.79",
- "@meshsdk/common": "1.9.0-beta.79",
- "@meshsdk/core-cst": "1.9.0-beta.79",
+ "@meshsdk/bitcoin": "1.9.0-beta.80",
+ "@meshsdk/common": "1.9.0-beta.80",
+ "@meshsdk/core-cst": "1.9.0-beta.80",
"@utxorpc/sdk": "^0.6.7",
"@utxorpc/spec": "^0.16.0",
"axios": "^1.7.2",
@@ -37899,14 +37846,14 @@
},
"packages/mesh-react": {
"name": "@meshsdk/react",
- "version": "1.9.0-beta.79",
+ "version": "1.9.0-beta.80",
"license": "Apache-2.0",
"dependencies": {
"@fabianbormann/cardano-peer-connect": "^1.2.18",
- "@meshsdk/bitcoin": "1.9.0-beta.79",
- "@meshsdk/common": "1.9.0-beta.79",
- "@meshsdk/transaction": "1.9.0-beta.79",
- "@meshsdk/wallet": "1.9.0-beta.79",
+ "@meshsdk/bitcoin": "1.9.0-beta.80",
+ "@meshsdk/common": "1.9.0-beta.80",
+ "@meshsdk/transaction": "1.9.0-beta.80",
+ "@meshsdk/wallet": "1.9.0-beta.80",
"@meshsdk/web3-sdk": "0.0.50",
"@radix-ui/react-dialog": "^1.1.2",
"@radix-ui/react-dropdown-menu": "^2.1.2",
@@ -37944,10 +37891,10 @@
},
"packages/mesh-svelte": {
"name": "@meshsdk/svelte",
- "version": "1.9.0-beta.79",
+ "version": "1.9.0-beta.80",
"license": "Apache-2.0",
"dependencies": {
- "@meshsdk/core": "1.9.0-beta.79",
+ "@meshsdk/core": "1.9.0-beta.80",
"bits-ui": "1.0.0-next.65"
},
"devDependencies": {
@@ -37973,14 +37920,14 @@
},
"packages/mesh-transaction": {
"name": "@meshsdk/transaction",
- "version": "1.9.0-beta.79",
+ "version": "1.9.0-beta.80",
"license": "Apache-2.0",
"dependencies": {
"@cardano-sdk/core": "^0.45.5",
"@cardano-sdk/input-selection": "^0.13.33",
"@cardano-sdk/util": "^0.15.5",
- "@meshsdk/common": "1.9.0-beta.79",
- "@meshsdk/core-cst": "1.9.0-beta.79",
+ "@meshsdk/common": "1.9.0-beta.80",
+ "@meshsdk/core-cst": "1.9.0-beta.80",
"json-bigint": "^1.0.0"
},
"devDependencies": {
@@ -37993,12 +37940,12 @@
},
"packages/mesh-wallet": {
"name": "@meshsdk/wallet",
- "version": "1.9.0-beta.79",
+ "version": "1.9.0-beta.80",
"license": "Apache-2.0",
"dependencies": {
- "@meshsdk/common": "1.9.0-beta.79",
- "@meshsdk/core-cst": "1.9.0-beta.79",
- "@meshsdk/transaction": "1.9.0-beta.79",
+ "@meshsdk/common": "1.9.0-beta.80",
+ "@meshsdk/core-cst": "1.9.0-beta.80",
+ "@meshsdk/transaction": "1.9.0-beta.80",
"@simplewebauthn/browser": "^13.0.0"
},
"devDependencies": {
@@ -38074,7 +38021,7 @@
},
"scripts/mesh-cli": {
"name": "meshjs",
- "version": "1.9.0-beta.79",
+ "version": "1.9.0-beta.80",
"license": "Apache-2.0",
"dependencies": {
"@sidan-lab/cardano-bar": "^0.0.7",
diff --git a/packages/bitcoin/package.json b/packages/bitcoin/package.json
index e9c7b9a74..bf5cce874 100644
--- a/packages/bitcoin/package.json
+++ b/packages/bitcoin/package.json
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/bitcoin",
- "version": "1.9.0-beta.80",
+ "version": "1.9.0-beta.81",
"description": "Mesh Bitcoin package",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
diff --git a/packages/mesh-common/package.json b/packages/mesh-common/package.json
index 137afa457..a31ce49d0 100644
--- a/packages/mesh-common/package.json
+++ b/packages/mesh-common/package.json
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/common",
- "version": "1.9.0-beta.80",
+ "version": "1.9.0-beta.81",
"description": "Contains constants, types and interfaces used across the SDK and different serialization libraries",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
diff --git a/packages/mesh-contract/package.json b/packages/mesh-contract/package.json
index 8ade50b7a..40bace655 100644
--- a/packages/mesh-contract/package.json
+++ b/packages/mesh-contract/package.json
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/contract",
- "version": "1.9.0-beta.80",
+ "version": "1.9.0-beta.81",
"description": "List of open-source smart contracts, complete with documentation, live demos, and end-to-end source code. https://meshjs.dev/smart-contracts",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
@@ -34,8 +34,8 @@
"typescript": "^5.3.3"
},
"dependencies": {
- "@meshsdk/common": "1.9.0-beta.80",
- "@meshsdk/core": "1.9.0-beta.80"
+ "@meshsdk/common": "1.9.0-beta.81",
+ "@meshsdk/core": "1.9.0-beta.81"
},
"prettier": "@meshsdk/configs/prettier",
"publishConfig": {
diff --git a/packages/mesh-core-csl/package.json b/packages/mesh-core-csl/package.json
index 4bc981215..08adf8f71 100644
--- a/packages/mesh-core-csl/package.json
+++ b/packages/mesh-core-csl/package.json
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/core-csl",
- "version": "1.9.0-beta.80",
+ "version": "1.9.0-beta.81",
"description": "Types and utilities functions between Mesh and cardano-serialization-lib",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -31,7 +31,7 @@
},
"devDependencies": {
"@meshsdk/configs": "*",
- "@meshsdk/provider": "1.9.0-beta.80",
+ "@meshsdk/provider": "1.9.0-beta.81",
"@types/json-bigint": "^1.0.4",
"eslint": "^8.57.0",
"ts-jest": "^29.1.4",
@@ -39,7 +39,7 @@
"typescript": "^5.3.3"
},
"dependencies": {
- "@meshsdk/common": "1.9.0-beta.80",
+ "@meshsdk/common": "1.9.0-beta.81",
"@sidan-lab/whisky-js-browser": "^1.0.11",
"@sidan-lab/whisky-js-nodejs": "^1.0.11",
"@types/base32-encoding": "^1.0.2",
diff --git a/packages/mesh-core-cst/package.json b/packages/mesh-core-cst/package.json
index 7bbce940b..565cd0201 100644
--- a/packages/mesh-core-cst/package.json
+++ b/packages/mesh-core-cst/package.json
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/core-cst",
- "version": "1.9.0-beta.80",
+ "version": "1.9.0-beta.81",
"description": "Types and utilities functions between Mesh and cardano-js-sdk",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
@@ -44,7 +44,7 @@
"@harmoniclabs/plutus-data": "1.2.4",
"@harmoniclabs/uplc": "1.2.4",
"@harmoniclabs/pair": "^1.0.0",
- "@meshsdk/common": "1.9.0-beta.80",
+ "@meshsdk/common": "1.9.0-beta.81",
"@types/base32-encoding": "^1.0.2",
"base32-encoding": "^1.0.0",
"bech32": "^2.0.0",
diff --git a/packages/mesh-core/package.json b/packages/mesh-core/package.json
index e572261f4..66cb9ae8e 100644
--- a/packages/mesh-core/package.json
+++ b/packages/mesh-core/package.json
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/core",
- "version": "1.9.0-beta.80",
+ "version": "1.9.0-beta.81",
"description": "Mesh SDK Core - https://meshjs.dev/",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
@@ -33,12 +33,12 @@
"typescript": "^5.3.3"
},
"dependencies": {
- "@meshsdk/common": "1.9.0-beta.80",
- "@meshsdk/core-cst": "1.9.0-beta.80",
- "@meshsdk/provider": "1.9.0-beta.80",
- "@meshsdk/react": "1.9.0-beta.80",
- "@meshsdk/transaction": "1.9.0-beta.80",
- "@meshsdk/wallet": "1.9.0-beta.80"
+ "@meshsdk/common": "1.9.0-beta.81",
+ "@meshsdk/core-cst": "1.9.0-beta.81",
+ "@meshsdk/provider": "1.9.0-beta.81",
+ "@meshsdk/react": "1.9.0-beta.81",
+ "@meshsdk/transaction": "1.9.0-beta.81",
+ "@meshsdk/wallet": "1.9.0-beta.81"
},
"prettier": "@meshsdk/configs/prettier",
"publishConfig": {
diff --git a/packages/mesh-hydra/package.json b/packages/mesh-hydra/package.json
index 4db23227b..81ab3c1ab 100644
--- a/packages/mesh-hydra/package.json
+++ b/packages/mesh-hydra/package.json
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/hydra",
- "version": "1.9.0-beta.80",
+ "version": "1.9.0-beta.81",
"description": "Mesh Hydra package",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
@@ -27,9 +27,9 @@
"test": "jest"
},
"dependencies": {
- "@meshsdk/common": "1.9.0-beta.80",
- "@meshsdk/core": "1.9.0-beta.80",
- "@meshsdk/core-cst": "1.9.0-beta.80",
+ "@meshsdk/common": "1.9.0-beta.81",
+ "@meshsdk/core": "1.9.0-beta.81",
+ "@meshsdk/core-cst": "1.9.0-beta.81",
"axios": "^1.7.2"
},
"devDependencies": {
diff --git a/packages/mesh-provider/package.json b/packages/mesh-provider/package.json
index c138f243e..760582f17 100644
--- a/packages/mesh-provider/package.json
+++ b/packages/mesh-provider/package.json
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/provider",
- "version": "1.9.0-beta.80",
+ "version": "1.9.0-beta.81",
"description": "Blockchain data providers - https://meshjs.dev/providers",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
@@ -35,9 +35,9 @@
"typescript": "^5.3.3"
},
"dependencies": {
- "@meshsdk/bitcoin": "1.9.0-beta.80",
- "@meshsdk/common": "1.9.0-beta.80",
- "@meshsdk/core-cst": "1.9.0-beta.80",
+ "@meshsdk/bitcoin": "1.9.0-beta.81",
+ "@meshsdk/common": "1.9.0-beta.81",
+ "@meshsdk/core-cst": "1.9.0-beta.81",
"@utxorpc/sdk": "^0.6.7",
"@utxorpc/spec": "^0.16.0",
"axios": "^1.7.2",
diff --git a/packages/mesh-react/package.json b/packages/mesh-react/package.json
index 61a34a303..73c255c60 100644
--- a/packages/mesh-react/package.json
+++ b/packages/mesh-react/package.json
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/react",
- "version": "1.9.0-beta.80",
+ "version": "1.9.0-beta.81",
"description": "React component library - https://meshjs.dev/react",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
@@ -30,10 +30,10 @@
},
"dependencies": {
"@fabianbormann/cardano-peer-connect": "^1.2.18",
- "@meshsdk/bitcoin": "1.9.0-beta.80",
- "@meshsdk/common": "1.9.0-beta.80",
- "@meshsdk/transaction": "1.9.0-beta.80",
- "@meshsdk/wallet": "1.9.0-beta.80",
+ "@meshsdk/bitcoin": "1.9.0-beta.81",
+ "@meshsdk/common": "1.9.0-beta.81",
+ "@meshsdk/transaction": "1.9.0-beta.81",
+ "@meshsdk/wallet": "1.9.0-beta.81",
"@meshsdk/web3-sdk": "0.0.50",
"@radix-ui/react-dialog": "^1.1.2",
"@radix-ui/react-dropdown-menu": "^2.1.2",
diff --git a/packages/mesh-svelte/package.json b/packages/mesh-svelte/package.json
index 57b143777..46ae9c54b 100644
--- a/packages/mesh-svelte/package.json
+++ b/packages/mesh-svelte/package.json
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/svelte",
- "version": "1.9.0-beta.80",
+ "version": "1.9.0-beta.81",
"description": "Svelte component library - https://meshjs.dev/svelte",
"type": "module",
"exports": {
@@ -26,7 +26,7 @@
"dev": "vite dev"
},
"dependencies": {
- "@meshsdk/core": "1.9.0-beta.80",
+ "@meshsdk/core": "1.9.0-beta.81",
"bits-ui": "1.0.0-next.65"
},
"devDependencies": {
diff --git a/packages/mesh-transaction/package.json b/packages/mesh-transaction/package.json
index c4a58b15e..c86d846c4 100644
--- a/packages/mesh-transaction/package.json
+++ b/packages/mesh-transaction/package.json
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/transaction",
- "version": "1.9.0-beta.80",
+ "version": "1.9.0-beta.81",
"description": "Transactions - https://meshjs.dev/apis/transaction",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
@@ -35,8 +35,8 @@
"typescript": "^5.3.3"
},
"dependencies": {
- "@meshsdk/common": "1.9.0-beta.80",
- "@meshsdk/core-cst": "1.9.0-beta.80",
+ "@meshsdk/common": "1.9.0-beta.81",
+ "@meshsdk/core-cst": "1.9.0-beta.81",
"@cardano-sdk/core": "^0.45.5",
"@cardano-sdk/util": "^0.15.5",
"@cardano-sdk/input-selection": "^0.13.33",
diff --git a/packages/mesh-wallet/package.json b/packages/mesh-wallet/package.json
index 6e1f29546..2ebd16eb4 100644
--- a/packages/mesh-wallet/package.json
+++ b/packages/mesh-wallet/package.json
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/wallet",
- "version": "1.9.0-beta.80",
+ "version": "1.9.0-beta.81",
"description": "Wallets - https://meshjs.dev/apis/wallets",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
@@ -35,9 +35,9 @@
"typescript": "^5.3.3"
},
"dependencies": {
- "@meshsdk/common": "1.9.0-beta.80",
- "@meshsdk/core-cst": "1.9.0-beta.80",
- "@meshsdk/transaction": "1.9.0-beta.80",
+ "@meshsdk/common": "1.9.0-beta.81",
+ "@meshsdk/core-cst": "1.9.0-beta.81",
+ "@meshsdk/transaction": "1.9.0-beta.81",
"@simplewebauthn/browser": "^13.0.0"
},
"prettier": "@meshsdk/configs/prettier",
diff --git a/packages/midnight-setup/.npmignore b/packages/midnight-setup/.npmignore
index 3fd026b50..667d5be59 100644
--- a/packages/midnight-setup/.npmignore
+++ b/packages/midnight-setup/.npmignore
@@ -7,10 +7,6 @@ src/
# Build artifacts not needed
.turbo
-# Yarn/workspace files (we use npm in main repo)
-yarn.lock
-turbo.json
-
# Development configs
tsconfig.json
tsup.config.ts
@@ -30,4 +26,3 @@ tests/
# Misc
*.log
.DS_Store
-
diff --git a/packages/midnight-setup/LICENSE b/packages/midnight-setup/LICENSE
index f313fef23..fc05a9754 100644
--- a/packages/midnight-setup/LICENSE
+++ b/packages/midnight-setup/LICENSE
@@ -1,21 +1,201 @@
-MIT License
-
-Copyright (c) 2025 luislucena16
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
\ No newline at end of file
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright 2023 MeshJS
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/packages/midnight-setup/README.md b/packages/midnight-setup/README.md
index 30d1f59ea..db7e9c692 100644
--- a/packages/midnight-setup/README.md
+++ b/packages/midnight-setup/README.md
@@ -1,19 +1,19 @@
-# @meshsdk/midnight-setup
-
-
🚀 The fastest way to build on Midnight Network
+
The fastest way to build on Midnight Network
Pre-built smart contract + Complete API + Ready-to-use code snippets
[](https://www.npmjs.com/package/@meshsdk/midnight-setup)
- [](https://opensource.org/licenses/MIT)
+ [](https://opensource.org/licenses/Apache2.0)
[](https://www.typescriptlang.org/)
---
-## ⚡ Quick Start (2 minutes)
+> Source repository with a full React integration example and a Compact contract: https://github.com/MeshJS/midnight-setup
+
+---
-### Step 1: Install
+## Installation
```bash
npm install @meshsdk/midnight-setup \
@@ -25,127 +25,53 @@ npm install @meshsdk/midnight-setup \
@midnight-ntwrk/midnight-js-network-id@2.0.2
```
-**What happens automatically:**
-- ✅ ZK parameters are downloaded to `.cache/midnight/zk-params/`
-- ✅ All dependencies are installed
-- ✅ Your project is ready to use Midnight Network
-
-> **Note:** The ZK params download (~50MB) runs automatically after installation. If it fails, you can run it manually:
-> ```bash
-> sh node_modules/@meshsdk/midnight-setup/fetch-zk-params.sh
-> ```
-
-### Step 2: Install Lace Beta Wallet
-
-Download and install: [Lace Beta Wallet for Midnight](https://chromewebstore.google.com/detail/lace-beta/djcdfchkaijggdjokfomholkalbffgil)
-
-1. Create a new wallet
-2. Switch to **Midnight Testnet** in settings
-3. Make sure you have at least one account
-
-### Step 3: Setup Your Project (Copy Required Files)
-
-See the **"🎯 Complete Hello World"** section below for all the files you need to copy.
-
-### Step 4: Run Your dApp
-
-```bash
-npm run dev
-```
-
-Open http://localhost:5173 and click "Deploy New Contract"
-
-**That's it! You have a working Midnight dApp!** 🎉
-
---
-## 🚀 Quick Deploy - One Code Block
-
-```typescript
-import { MidnightSetupAPI } from '@meshsdk/midnight-setup';
-import { setupProviders } from './providers'; // See below ⬇️
+## Features
-async function deployMyContract() {
- // 1. Setup providers (wallet connection)
- const providers = await setupProviders();
-
- // 2. Deploy contract
- const api = await MidnightSetupAPI.deployMidnightSetupContract(providers);
-
- // 3. Read the state
- const state = await api.getLedgerState();
-
- console.log('✅ Contract deployed at:', api.deployedContractAddress);
- console.log('💬 Message:', state.ledgerState?.message);
- // Output: "Made with ❤️ by MeshJS team!"
-}
-```
+- **Type-safe SDK** - Full TypeScript support
+- **Provider abstraction** - Easy wallet and network integration
+- **Contract state management** - Query contract and ledger states
+- **Flexible contract support** - Works with any Midnight smart contract
+- **Lightweight** - Only 10.4 KB package size
+- **ESM & CJS** - Supports both module systems
---
-## 🎯 Complete Hello World - Copy & Paste These Files
+## Quick Start
-Here's a **complete working dApp** you can copy and paste. Create these files in your project:
+### 1. Setup Providers
-### File Structure
-```
-my-midnight-dapp/
-├── src/
-│ ├── lib/
-│ │ └── providers.ts ← Copy this
-│ ├── hooks/
-│ │ └── useMidnightContract.ts ← Copy this
-│ ├── App.tsx ← Copy this
-│ ├── polyfills.ts ← Copy this
-│ └── main.tsx ← Update this
-├── index.html
-├── vite.config.ts ← Update this
-└── package.json
-```
-
-### 📄 File 1: `src/polyfills.ts`
```typescript
-import { Buffer } from 'buffer';
-
-window.Buffer = Buffer;
-window.global = window.global || window;
-window.process = window.process || { env: {} };
+import { FetchZkConfigProvider } from "@midnight-ntwrk/midnight-js-fetch-zk-config-provider";
+import { httpClientProofProvider } from "@midnight-ntwrk/midnight-js-http-client-proof-provider";
+import { indexerPublicDataProvider } from "@midnight-ntwrk/midnight-js-indexer-public-data-provider";
+import { levelPrivateStateProvider } from "@midnight-ntwrk/midnight-js-level-private-state-provider";
-export { Buffer };
-```
-
-### 📄 File 2: `src/lib/providers.ts`
-```typescript
-import { levelPrivateStateProvider } from '@midnight-ntwrk/midnight-js-level-private-state-provider';
-import { FetchZkConfigProvider } from '@midnight-ntwrk/midnight-js-fetch-zk-config-provider';
-import { httpClientProofProvider } from '@midnight-ntwrk/midnight-js-http-client-proof-provider';
-import { indexerPublicDataProvider } from '@midnight-ntwrk/midnight-js-indexer-public-data-provider';
-import type { MidnightSetupContractProviders } from '@meshsdk/midnight-setup';
+import type { MidnightSetupContractProviders } from "@meshsdk/midnight-setup";
export async function setupProviders(): Promise {
- // Connect to Lace Wallet
const wallet = window.midnight?.mnLace;
if (!wallet) {
- throw new Error('Please install Lace Beta Wallet for Midnight Network');
+ throw new Error("Please install Lace Beta Wallet for Midnight Network");
}
- // Enable wallet and get state
const walletAPI = await wallet.enable();
const walletState = await walletAPI.state();
const uris = await wallet.serviceUriConfig();
return {
privateStateProvider: levelPrivateStateProvider({
- privateStateStoreName: 'my-dapp-state',
+ privateStateStoreName: "my-dapp-state",
}),
zkConfigProvider: new FetchZkConfigProvider(
window.location.origin,
- fetch.bind(window)
+ fetch.bind(window),
),
proofProvider: httpClientProofProvider(uris.proverServerUri),
publicDataProvider: indexerPublicDataProvider(
uris.indexerUri,
- uris.indexerWsUri
+ uris.indexerWsUri,
),
walletProvider: {
coinPublicKey: walletState.coinPublicKey,
@@ -161,891 +87,163 @@ export async function setupProviders(): Promise
},
};
}
-
-// TypeScript declaration for window.midnight
-declare global {
- interface Window {
- midnight?: {
- mnLace?: any;
- };
- }
-}
-```
-
-### 📄 File 3: `src/hooks/useMidnightContract.ts`
-```typescript
-import { useState, useCallback } from 'react';
-import { MidnightSetupAPI, type DeployedMidnightSetupAPI } from '@meshsdk/midnight-setup';
-import { setupProviders } from '../lib/providers';
-
-export function useMidnightContract() {
- const [api, setApi] = useState(null);
- const [loading, setLoading] = useState(false);
- const [error, setError] = useState(null);
-
- const deployContract = useCallback(async () => {
- setLoading(true);
- setError(null);
- try {
- const providers = await setupProviders();
- const newApi = await MidnightSetupAPI.deployMidnightSetupContract(providers);
- setApi(newApi);
- return newApi;
- } catch (err) {
- const message = err instanceof Error ? err.message : 'Failed to deploy';
- setError(message);
- throw err;
- } finally {
- setLoading(false);
- }
- }, []);
-
- const joinContract = useCallback(async (address: string) => {
- setLoading(true);
- setError(null);
- try {
- const providers = await setupProviders();
- const newApi = await MidnightSetupAPI.joinMidnightSetupContract(providers, address);
- setApi(newApi);
- return newApi;
- } catch (err) {
- const message = err instanceof Error ? err.message : 'Failed to join';
- setError(message);
- throw err;
- } finally {
- setLoading(false);
- }
- }, []);
-
- return {
- api,
- loading,
- error,
- deployContract,
- joinContract,
- };
-}
-```
-
-### 📄 File 4: `src/App.tsx`
-```typescript
-import { useState, useEffect } from 'react';
-import { useMidnightContract } from './hooks/useMidnightContract';
-
-function App() {
- const { api, loading, error, deployContract, joinContract } = useMidnightContract();
- const [message, setMessage] = useState('');
- const [contractAddress, setContractAddress] = useState('');
-
- // Read contract state when API is ready
- useEffect(() => {
- if (api) {
- api.getLedgerState().then(state => {
- setMessage(state.ledgerState?.message || '');
- });
- }
- }, [api]);
-
- return (
-
-
-
- 🌙 My Midnight dApp
-
-
- Built with @meshsdk/midnight-setup
-
-
- {/* Deploy new contract */}
- {!api && (
-
-
{
- if (!loading) e.currentTarget.style.transform = 'scale(1.02)';
- }}
- onMouseLeave={(e) => {
- e.currentTarget.style.transform = 'scale(1)';
- }}
- >
- {loading ? '⏳ Deploying...' : '🚀 Deploy New Contract'}
-
-
-
-
- Or join existing contract:
-
-
- setContractAddress(e.target.value)}
- style={{
- flex: 1,
- padding: '10px',
- fontSize: '14px',
- border: '2px solid #e0e0e0',
- borderRadius: '6px',
- outline: 'none'
- }}
- onFocus={(e) => e.currentTarget.style.borderColor = '#667eea'}
- onBlur={(e) => e.currentTarget.style.borderColor = '#e0e0e0'}
- />
- joinContract(contractAddress)}
- disabled={loading || !contractAddress}
- style={{
- padding: '10px 20px',
- fontSize: '14px',
- fontWeight: '600',
- color: 'white',
- background: (loading || !contractAddress) ? '#ccc' : '#667eea',
- border: 'none',
- borderRadius: '6px',
- cursor: (loading || !contractAddress) ? 'not-allowed' : 'pointer',
- }}
- >
- Join
-
-
-
-
- )}
-
- {/* Show error */}
- {error && (
-
- ❌ {error}
-
- )}
-
- {/* Show contract info */}
- {api && (
-
-
- ✅ Contract Connected
-
-
-
- 📍 Address:
-
- {api.deployedContractAddress}
-
-
-
- 💬 Message:
-
- {message || 'Loading...'}
-
-
-
-
- )}
-
-
- Made with ❤️ by MeshJS Team
-
-
-
- );
-}
-
-export default App;
-```
-
-### 📄 File 5: `src/main.tsx`
-```typescript
-import './polyfills'; // ← Add this FIRST
-import React from 'react';
-import ReactDOM from 'react-dom/client';
-import App from './App';
-
-ReactDOM.createRoot(document.getElementById('root')!).render(
-
-
-
-);
-```
-
-### 📄 File 6: `vite.config.ts`
-```typescript
-import { defineConfig } from 'vite';
-import react from '@vitejs/plugin-react';
-
-export default defineConfig({
- plugins: [react()],
- define: {
- 'global': 'globalThis',
- },
- resolve: {
- alias: {
- buffer: 'buffer',
- process: 'process/browser',
- },
- },
-});
-```
-
-### 📄 File 7: `package.json` dependencies
-```json
-{
- "dependencies": {
- "@meshsdk/midnight-setup": "^1.0.0",
- "@midnight-ntwrk/dapp-connector-api": "3.0.0",
- "@midnight-ntwrk/midnight-js-fetch-zk-config-provider": "2.0.2",
- "@midnight-ntwrk/midnight-js-http-client-proof-provider": "2.0.2",
- "@midnight-ntwrk/midnight-js-indexer-public-data-provider": "2.0.2",
- "@midnight-ntwrk/midnight-js-level-private-state-provider": "2.0.2",
- "@midnight-ntwrk/midnight-js-network-id": "2.0.2",
- "react": "^18.2.0",
- "react-dom": "^18.2.0",
- "buffer": "^6.0.3",
- "process": "^0.11.10"
- }
-}
-```
-
-### 🚀 Run Your dApp
-
-```bash
-# 1. Install all dependencies
-npm install
-
-# 2. Start development server
-npm run dev
-
-# 3. Open http://localhost:5173 in your browser
-# 4. Make sure Lace Beta Wallet is installed
-# 5. Click "Deploy New Contract"
```
-**That's it!** You now have a fully working Midnight Network dApp. 🎉
-
----
-
-## 📋 Ready-to-Use Code Snippets
-
-### 1. Provider Setup (Copy this helper function)
-
-Create `src/lib/providers.ts`:
+### 2. Deploy a Contract
```typescript
-import { levelPrivateStateProvider } from '@midnight-ntwrk/midnight-js-level-private-state-provider';
-import { FetchZkConfigProvider } from '@midnight-ntwrk/midnight-js-fetch-zk-config-provider';
-import { httpClientProofProvider } from '@midnight-ntwrk/midnight-js-http-client-proof-provider';
-import { indexerPublicDataProvider } from '@midnight-ntwrk/midnight-js-indexer-public-data-provider';
-import type { MidnightSetupContractProviders } from '@meshsdk/midnight-setup';
+import { MidnightSetupAPI } from "@meshsdk/midnight-setup";
-export async function setupProviders(): Promise {
- // Connect to Lace Wallet
- const wallet = window.midnight?.mnLace;
- if (!wallet) {
- throw new Error('Please install Lace Beta Wallet for Midnight Network');
- }
+import { setupProviders } from "./providers";
- // Enable wallet and get state
- const walletAPI = await wallet.enable();
- const walletState = await walletAPI.state();
- const uris = await wallet.serviceUriConfig();
-
- return {
- privateStateProvider: levelPrivateStateProvider({
- privateStateStoreName: 'my-dapp-state',
- }),
- zkConfigProvider: new FetchZkConfigProvider(
- window.location.origin,
- fetch.bind(window)
- ),
- proofProvider: httpClientProofProvider(uris.proverServerUri),
- publicDataProvider: indexerPublicDataProvider(
- uris.indexerUri,
- uris.indexerWsUri
- ),
- walletProvider: {
- coinPublicKey: walletState.coinPublicKey,
- encryptionPublicKey: walletState.encryptionPublicKey,
- balanceTx: (tx, newCoins) => {
- return walletAPI.balanceAndProveTransaction(tx, newCoins);
- },
- },
- midnightProvider: {
- submitTx: (tx) => {
- return walletAPI.submitTransaction(tx);
- },
- },
- };
-}
-```
-
-**Save this file once, use it everywhere in your project.** ✅
-
----
-
-### 2. React Hook (Copy & Paste - Production Ready)
-
-Create `src/hooks/useMidnightContract.ts`:
-
-```typescript
-import { useState, useCallback } from 'react';
-import { MidnightSetupAPI, type DeployedMidnightSetupAPI } from '@meshsdk/midnight-setup';
-import { setupProviders } from '../lib/providers';
-
-export function useMidnightContract() {
- const [api, setApi] = useState(null);
- const [loading, setLoading] = useState(false);
- const [error, setError] = useState(null);
-
- const deployContract = useCallback(async () => {
- setLoading(true);
- setError(null);
- try {
- const providers = await setupProviders();
- const newApi = await MidnightSetupAPI.deployMidnightSetupContract(providers);
- setApi(newApi);
- return newApi;
- } catch (err) {
- const message = err instanceof Error ? err.message : 'Failed to deploy';
- setError(message);
- throw err;
- } finally {
- setLoading(false);
- }
- }, []);
-
- const joinContract = useCallback(async (address: string) => {
- setLoading(true);
- setError(null);
- try {
- const providers = await setupProviders();
- const newApi = await MidnightSetupAPI.joinMidnightSetupContract(providers, address);
- setApi(newApi);
- return newApi;
- } catch (err) {
- const message = err instanceof Error ? err.message : 'Failed to join';
- setError(message);
- throw err;
- } finally {
- setLoading(false);
- }
- }, []);
-
- return {
- api,
- loading,
- error,
- deployContract,
- joinContract,
- };
-}
-```
-
-**Usage in your component:**
+async function deployContract() {
+ const providers = await setupProviders();
+ const contractInstance = new MyContract({});
-```typescript
-import { useMidnightContract } from './hooks/useMidnightContract';
-
-function MyComponent() {
- const { api, loading, error, deployContract } = useMidnightContract();
-
- return (
-
-
- {loading ? 'Deploying...' : 'Deploy Contract'}
-
- {error &&
Error: {error}
}
- {api &&
Contract: {api.deployedContractAddress}
}
-
+ const api = await MidnightSetupAPI.deployContract(
+ providers,
+ contractInstance,
);
-}
-```
-
----
-### 3. Complete React Component (Copy & Run)
-
-```typescript
-import { useState, useEffect } from 'react';
-import { useMidnightContract } from './hooks/useMidnightContract';
-
-export function MidnightDApp() {
- const { api, loading, error, deployContract, joinContract } = useMidnightContract();
- const [message, setMessage] = useState('');
- const [contractAddress, setContractAddress] = useState('');
-
- // Read contract state when API is ready
- useEffect(() => {
- if (api) {
- api.getLedgerState().then(state => {
- setMessage(state.ledgerState?.message || '');
- });
- }
- }, [api]);
-
- return (
-
-
My Midnight dApp
-
- {/* Deploy new contract */}
-
-
- {loading ? 'Deploying...' : 'Deploy New Contract'}
-
-
- {/* Or join existing */}
-
- setContractAddress(e.target.value)}
- style={{ padding: '8px', width: '300px' }}
- />
- joinContract(contractAddress)}
- disabled={loading || !contractAddress || !!api}
- style={{ padding: '8px 16px', marginLeft: '10px' }}
- >
- Join Contract
-
-
-
-
- {/* Show error */}
- {error && (
-
- Error: {error}
-
- )}
-
- {/* Show contract info */}
- {api && (
-
-
✅ Contract Ready
-
Address: {api.deployedContractAddress}
-
Message: {message}
-
- )}
-
- );
+ console.log("Contract deployed at:", api.deployedContractAddress);
+ return api;
}
```
-**This component is production-ready. Just import and use it!** 🎉
-
----
-
-## 🔥 Common Use Cases (Copy These)
-
-### Deploy and Save Address
+### 3. Join Existing Contract
```typescript
-const api = await MidnightSetupAPI.deployMidnightSetupContract(providers);
-
-// Save to localStorage for later use
-localStorage.setItem('myContractAddress', api.deployedContractAddress);
-
-console.log('✅ Deployed:', api.deployedContractAddress);
-```
-
-### Load Existing Contract
-
-```typescript
-const savedAddress = localStorage.getItem('myContractAddress');
+async function joinContract(contractAddress: string) {
+ const providers = await setupProviders();
+ const contractInstance = new MyContract({});
-if (savedAddress) {
- const api = await MidnightSetupAPI.joinMidnightSetupContract(
+ const api = await MidnightSetupAPI.joinContract(
providers,
- savedAddress
+ contractInstance,
+ contractAddress,
);
- console.log('✅ Reconnected to contract');
+
+ return api;
}
```
-### Read Contract State
+### 4. Read Contract State
```typescript
-// Get full contract state
+// Get contract state
const contractState = await api.getContractState();
-console.log('Raw data:', contractState.data);
-console.log('Block:', contractState.blockHeight);
+console.log("Contract data:", contractState.data);
-// Get parsed ledger state (easier to use)
+// Get ledger state
const ledgerState = await api.getLedgerState();
-console.log('Message:', ledgerState.ledgerState?.message);
-```
-
-### Listen to State Changes (Real-time)
-
-```typescript
-api.state.subscribe({
- next: (state) => {
- console.log('State updated:', state);
- // Update your UI here
- },
- error: (err) => {
- console.error('State error:', err);
- }
-});
-```
-
-### With Logging (for Development)
-
-```typescript
-import pino from 'pino';
-
-const logger = pino({ level: 'debug' });
-
-const api = await MidnightSetupAPI.deployMidnightSetupContract(
- providers,
- logger
-);
-
-// Now you'll see detailed logs in console
-```
-
----
-
-## 🎨 Next.js Example (App Router)
-
-Create `app/midnight/page.tsx`:
-
-```typescript
-'use client';
-
-import { useState } from 'react';
-import { MidnightSetupAPI } from '@meshsdk/midnight-setup';
-import { setupProviders } from '@/lib/providers';
-
-export default function MidnightPage() {
- const [status, setStatus] = useState('');
-
- const deployContract = async () => {
- try {
- setStatus('Deploying...');
-
- const providers = await setupProviders();
- const api = await MidnightSetupAPI.deployMidnightSetupContract(providers);
-
- setStatus(`✅ Deployed at: ${api.deployedContractAddress}`);
- } catch (error) {
- setStatus(`❌ Error: ${error.message}`);
- }
- };
-
- return (
-
- Midnight dApp
-
- Deploy Contract
-
- {status && {status}
}
-
- );
-}
+console.log("Message:", ledgerState.ledgerState?.message);
```
---
-## 🛠️ Vite + React Setup
-
-### 1. Install Vite polyfills
-
-```bash
-npm install buffer process
-```
-
-### 2. Create `src/polyfills.ts`:
-
-```typescript
-import { Buffer } from 'buffer';
+## API Reference
-window.Buffer = Buffer;
-window.global = window.global || window;
-window.process = window.process || { env: {} };
+### MidnightSetupAPI
-export { Buffer };
-```
+#### Static Methods
-### 3. Import in `src/main.tsx`:
-
-```typescript
-import './polyfills'; // Add this first
-import React from 'react';
-import ReactDOM from 'react-dom/client';
-import App from './App';
-
-ReactDOM.createRoot(document.getElementById('root')!).render(
-
-
-
-);
-```
+**`deployContract(providers, contractInstance, logger?)`**
-### 4. Update `vite.config.ts`:
-
-```typescript
-import { defineConfig } from 'vite';
-import react from '@vitejs/plugin-react';
-
-export default defineConfig({
- plugins: [react()],
- define: {
- 'global': 'globalThis',
- },
- resolve: {
- alias: {
- buffer: 'buffer',
- process: 'process/browser',
- },
- },
-});
-```
-
----
-
-## 📦 What's Included
-
-This package gives you everything you need:
-
-- ✅ **Pre-compiled Smart Contract** - No need to learn Compact
-- ✅ **Complete TypeScript API** - Full type safety
-- ✅ **Wallet Integration** - Works with Lace Beta Wallet
-- ✅ **State Management** - Private & public state handling
-- ✅ **Zero Configuration** - Just install and use
-
----
-
-## 📚 API Reference
-
-### `MidnightSetupAPI.deployMidnightSetupContract(providers, logger?)`
-
-Deploy a new contract.
+Deploys a new smart contract to Midnight Network.
**Parameters:**
-- `providers: MidnightSetupContractProviders` - Required (see provider setup above)
+
+- `providers: MidnightSetupContractProviders` - Network and wallet providers
+- `contractInstance: ContractInstance` - Your compiled contract instance
- `logger?: Logger` - Optional Pino logger
**Returns:** `Promise`
-**Example:**
-```typescript
-const api = await MidnightSetupAPI.deployMidnightSetupContract(providers);
-```
-
---
-### `MidnightSetupAPI.joinMidnightSetupContract(providers, address, logger?)`
+**`joinContract(providers, contractInstance, contractAddress, logger?)`**
-Connect to existing contract.
+Connects to an existing deployed contract.
**Parameters:**
-- `providers: MidnightSetupContractProviders` - Required
-- `address: string` - Contract address
-- `logger?: Logger` - Optional
-**Returns:** `Promise`
+- `providers: MidnightSetupContractProviders` - Network and wallet providers
+- `contractInstance: ContractInstance` - Your compiled contract instance
+- `contractAddress: string` - Address of the deployed contract
+- `logger?: Logger` - Optional Pino logger
-**Example:**
-```typescript
-const api = await MidnightSetupAPI.joinMidnightSetupContract(
- providers,
- '0x123abc...'
-);
-```
+**Returns:** `Promise`
---
-### `api.getContractState()`
+#### Instance Methods
-Get raw contract state.
+**`getContractState()`** - Gets the current state of the contract
**Returns:** `Promise`
-```typescript
-const state = await api.getContractState();
-// {
-// address: string,
-// data: unknown,
-// blockHeight?: string,
-// blockHash?: string,
-// error?: string
-// }
-```
-
----
-
-### `api.getLedgerState()`
-
-Get parsed ledger state.
+**`getLedgerState()`** - Gets and parses the ledger state
**Returns:** `Promise`
-```typescript
-const ledger = await api.getLedgerState();
-// {
-// address: string,
-// ledgerState?: {
-// message: string | null
-// },
-// blockHeight?: string,
-// error?: string
-// }
-```
-
---
-### `api.deployedContractAddress`
-
-Get contract address.
-
-**Type:** `string`
+## TypeScript Types
```typescript
-console.log(api.deployedContractAddress);
-// "0x123abc..."
+import type {
+ ContractInstance,
+ ContractStateData,
+ DeployedContract,
+ DeployedMidnightSetupAPI,
+ LedgerStateData,
+ MidnightSetupContractProviders,
+} from "@meshsdk/midnight-setup";
```
---
-### `api.state`
+## Requirements
-Observable for state changes.
-
-**Type:** `Observable`
-
-```typescript
-api.state.subscribe(state => {
- console.log('New state:', state);
-});
-```
+- Node.js v18 or higher
+- Midnight Lace Wallet browser extension
+- TypeScript (recommended)
---
-## 🔐 TypeScript Types
-
-All types are fully exported:
+## Links
-```typescript
-import type {
- MidnightSetupAPI,
- DeployedMidnightSetupAPI,
- MidnightSetupContractProviders,
- ContractStateData,
- LedgerStateData,
- DerivedMidnightSetupContractState,
- TokenCircuitKeys,
-} from '@meshsdk/midnight-setup';
-```
+- [Source Repository](https://github.com/MeshJS/midnight-setup)
+- [MeshJS Website](https://meshjs.dev)
+- [Midnight Network](https://midnight.network)
+- [Midnight Documentation](https://docs.midnight.network)
+- [npm Package](https://www.npmjs.com/package/@meshsdk/midnight-setup)
---
-## 🔗 Resources
+## Contributing
-- 📖 [Midnight Network Docs](https://docs.midnight.network)
-- 💬 [MeshJS Discord](https://discord.gg/meshjs)
-- 🐛 [Report Issues](https://github.com/MeshJS/midnight-setup/issues)
-- 💻 [Source Code](https://github.com/MeshJS/midnight-setup)
-- 🌐 [MeshJS Website](https://meshjs.dev)
+Contributions are welcome! Please visit the [source repository](https://github.com/MeshJS/midnight-setup).
---
-## 📄 License
+## License
-MIT © [MeshJS Team](https://github.com/MeshJS)
-
----
+Apache2.0 © [MeshJS Team](https://github.com/MeshJS)
-## ⚡ Start Building Now
+See [LICENSE](./LICENSE) for more information.
-```bash
-npm install @meshsdk/midnight-setup
-```
+---
-Copy the code snippets above and start building your Midnight dApp in minutes! 🚀
+## Support
-**Questions?** [Open an issue](https://github.com/MeshJS/midnight-setup/issues) and we'll help you.
+- [Report Issues](https://github.com/MeshJS/midnight-setup/issues)
+- [Discord Community](https://discord.gg/hBJNSwXE2S)
+- [Twitter](https://twitter.com/meshsdk)
---
-
Made with ❤️ by MeshJS Team
+
Built with ❤️ by the MeshJS Team
+
Powered by Midnight Network
diff --git a/packages/midnight-setup/contract-compiled/index.d.ts b/packages/midnight-setup/contract-compiled/index.d.ts
deleted file mode 100644
index a7bd1562b..000000000
--- a/packages/midnight-setup/contract-compiled/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./managed/midnight-setup/contract/index.cjs";
diff --git a/packages/midnight-setup/contract-compiled/index.js b/packages/midnight-setup/contract-compiled/index.js
deleted file mode 100644
index 3a40c7940..000000000
--- a/packages/midnight-setup/contract-compiled/index.js
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from "./managed/midnight-setup/contract/index.cjs";
-//# sourceMappingURL=index.js.map
\ No newline at end of file
diff --git a/packages/midnight-setup/contract-compiled/index.js.map b/packages/midnight-setup/contract-compiled/index.js.map
deleted file mode 100644
index 002bb8f0b..000000000
--- a/packages/midnight-setup/contract-compiled/index.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,6CAA6C,CAAC"}
\ No newline at end of file
diff --git a/packages/midnight-setup/contract-compiled/managed/midnight-setup/compiler/contract-info.json b/packages/midnight-setup/contract-compiled/managed/midnight-setup/compiler/contract-info.json
deleted file mode 100644
index 929962bf5..000000000
--- a/packages/midnight-setup/contract-compiled/managed/midnight-setup/compiler/contract-info.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "circuits": [
- ],
- "witnesses": [
- ],
- "contracts": [
- ]
-}
diff --git a/packages/midnight-setup/contract-compiled/managed/midnight-setup/contract/index.cjs b/packages/midnight-setup/contract-compiled/managed/midnight-setup/contract/index.cjs
deleted file mode 100644
index 615aeba27..000000000
--- a/packages/midnight-setup/contract-compiled/managed/midnight-setup/contract/index.cjs
+++ /dev/null
@@ -1,180 +0,0 @@
-'use strict';
-const __compactRuntime = require('@midnight-ntwrk/compact-runtime');
-const expectedRuntimeVersionString = '0.8.1';
-const expectedRuntimeVersion = expectedRuntimeVersionString.split('-')[0].split('.').map(Number);
-const actualRuntimeVersion = __compactRuntime.versionString.split('-')[0].split('.').map(Number);
-if (expectedRuntimeVersion[0] != actualRuntimeVersion[0]
- || (actualRuntimeVersion[0] == 0 && expectedRuntimeVersion[1] != actualRuntimeVersion[1])
- || expectedRuntimeVersion[1] > actualRuntimeVersion[1]
- || (expectedRuntimeVersion[1] == actualRuntimeVersion[1] && expectedRuntimeVersion[2] > actualRuntimeVersion[2]))
- throw new __compactRuntime.CompactError(`Version mismatch: compiled code expects ${expectedRuntimeVersionString}, runtime is ${__compactRuntime.versionString}`);
-{ const MAX_FIELD = 52435875175126190479447740508185965837690552500527637822603658699938581184512n;
- if (__compactRuntime.MAX_FIELD !== MAX_FIELD)
- throw new __compactRuntime.CompactError(`compiler thinks maximum field value is ${MAX_FIELD}; run time thinks it is ${__compactRuntime.MAX_FIELD}`)
-}
-
-const _descriptor_0 = new __compactRuntime.CompactTypeUnsignedInteger(18446744073709551615n, 8);
-
-const _descriptor_1 = new __compactRuntime.CompactTypeBoolean();
-
-const _descriptor_2 = new __compactRuntime.CompactTypeBytes(32);
-
-class _ContractAddress_0 {
- alignment() {
- return _descriptor_2.alignment();
- }
- fromValue(value_0) {
- return {
- bytes: _descriptor_2.fromValue(value_0)
- }
- }
- toValue(value_0) {
- return _descriptor_2.toValue(value_0.bytes);
- }
-}
-
-const _descriptor_3 = new _ContractAddress_0();
-
-const _descriptor_4 = new __compactRuntime.CompactTypeUnsignedInteger(255n, 1);
-
-const _descriptor_5 = new __compactRuntime.CompactTypeUnsignedInteger(340282366920938463463374607431768211455n, 16);
-
-class Contract {
- witnesses;
- constructor(...args_0) {
- if (args_0.length !== 1) {
- throw new __compactRuntime.CompactError(`Contract constructor: expected 1 argument, received ${args_0.length}`);
- }
- const witnesses_0 = args_0[0];
- if (typeof(witnesses_0) !== 'object') {
- throw new __compactRuntime.CompactError('first (witnesses) argument to Contract constructor is not an object');
- }
- this.witnesses = witnesses_0;
- this.circuits = {
- };
- this.impureCircuits = {};
- }
- initialState(...args_0) {
- if (args_0.length !== 1) {
- throw new __compactRuntime.CompactError(`Contract state constructor: expected 1 argument (as invoked from Typescript), received ${args_0.length}`);
- }
- const constructorContext_0 = args_0[0];
- if (typeof(constructorContext_0) !== 'object') {
- throw new __compactRuntime.CompactError(`Contract state constructor: expected 'constructorContext' in argument 1 (as invoked from Typescript) to be an object`);
- }
- if (!('initialZswapLocalState' in constructorContext_0)) {
- throw new __compactRuntime.CompactError(`Contract state constructor: expected 'initialZswapLocalState' in argument 1 (as invoked from Typescript)`);
- }
- if (typeof(constructorContext_0.initialZswapLocalState) !== 'object') {
- throw new __compactRuntime.CompactError(`Contract state constructor: expected 'initialZswapLocalState' in argument 1 (as invoked from Typescript) to be an object`);
- }
- const state_0 = new __compactRuntime.ContractState();
- let stateValue_0 = __compactRuntime.StateValue.newArray();
- stateValue_0 = stateValue_0.arrayPush(__compactRuntime.StateValue.newNull());
- state_0.data = stateValue_0;
- const context = {
- originalState: state_0,
- currentPrivateState: constructorContext_0.initialPrivateState,
- currentZswapLocalState: constructorContext_0.initialZswapLocalState,
- transactionContext: new __compactRuntime.QueryContext(state_0.data, __compactRuntime.dummyContractAddress())
- };
- const partialProofData = {
- input: { value: [], alignment: [] },
- output: undefined,
- publicTranscript: [],
- privateTranscriptOutputs: []
- };
- Contract._query(context,
- partialProofData,
- [
- { push: { storage: false,
- value: __compactRuntime.StateValue.newCell({ value: _descriptor_4.toValue(0n),
- alignment: _descriptor_4.alignment() }).encode() } },
- { push: { storage: true,
- value: __compactRuntime.StateValue.newCell({ value: _descriptor_2.toValue(new Uint8Array(32)),
- alignment: _descriptor_2.alignment() }).encode() } },
- { ins: { cached: false, n: 1 } }]);
- Contract._query(context,
- partialProofData,
- [
- { push: { storage: false,
- value: __compactRuntime.StateValue.newCell({ value: _descriptor_4.toValue(0n),
- alignment: _descriptor_4.alignment() }).encode() } },
- { push: { storage: true,
- value: __compactRuntime.StateValue.newCell({ value: _descriptor_2.toValue(new Uint8Array([77, 97, 100, 101, 32, 119, 105, 116, 104, 32, 226, 157, 164, 239, 184, 143, 32, 98, 121, 32, 77, 101, 115, 104, 74, 83, 32, 116, 101, 97, 109, 33])),
- alignment: _descriptor_2.alignment() }).encode() } },
- { ins: { cached: false, n: 1 } }]);
- state_0.data = context.transactionContext.state;
- return {
- currentContractState: state_0,
- currentPrivateState: context.currentPrivateState,
- currentZswapLocalState: context.currentZswapLocalState
- }
- }
- static _query(context, partialProofData, prog) {
- var res;
- try {
- res = context.transactionContext.query(prog, __compactRuntime.CostModel.dummyCostModel());
- } catch (err) {
- throw new __compactRuntime.CompactError(err.toString());
- }
- context.transactionContext = res.context;
- var reads = res.events.filter((e) => e.tag === 'read');
- var i = 0;
- partialProofData.publicTranscript = partialProofData.publicTranscript.concat(prog.map((op) => {
- if(typeof(op) === 'object' && 'popeq' in op) {
- return { popeq: {
- ...op.popeq,
- result: reads[i++].content,
- } };
- } else {
- return op;
- }
- }));
- if(res.events.length == 1 && res.events[0].tag === 'read') {
- return res.events[0].content;
- } else {
- return res.events;
- }
- }
-}
-function ledger(state) {
- const context = {
- originalState: state,
- transactionContext: new __compactRuntime.QueryContext(state, __compactRuntime.dummyContractAddress())
- };
- const partialProofData = {
- input: { value: [], alignment: [] },
- output: undefined,
- publicTranscript: [],
- privateTranscriptOutputs: []
- };
- return {
- get message() {
- return _descriptor_2.fromValue(Contract._query(context,
- partialProofData,
- [
- { dup: { n: 0 } },
- { idx: { cached: false,
- pushPath: false,
- path: [
- { tag: 'value',
- value: { value: _descriptor_4.toValue(0n),
- alignment: _descriptor_4.alignment() } }] } },
- { popeq: { cached: false,
- result: undefined } }]).value);
- }
- };
-}
-const _emptyContext = {
- originalState: new __compactRuntime.ContractState(),
- transactionContext: new __compactRuntime.QueryContext(new __compactRuntime.ContractState().data, __compactRuntime.dummyContractAddress())
-};
-const _dummyContract = new Contract({ });
-const pureCircuits = {};
-const contractReferenceLocations = { tag: 'publicLedgerArray', indices: { } };
-exports.Contract = Contract;
-exports.ledger = ledger;
-exports.pureCircuits = pureCircuits;
-exports.contractReferenceLocations = contractReferenceLocations;
-//# sourceMappingURL=index.cjs.map
diff --git a/packages/midnight-setup/contract-compiled/managed/midnight-setup/contract/index.cjs.map b/packages/midnight-setup/contract-compiled/managed/midnight-setup/contract/index.cjs.map
deleted file mode 100644
index ddeda7d98..000000000
--- a/packages/midnight-setup/contract-compiled/managed/midnight-setup/contract/index.cjs.map
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "version": 3,
- "file": "index.cjs",
- "sourceRoot": "../../../../",
- "sources": ["src/midnight-setup.compact"],
- "names": [],
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMA;;;;;;;;;;;;GAEC;EAFD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAFA;;;;;;;;;uDAAiC;IAG/B;;;;;;;;;uDAAO;;;;;;;GACR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAJD;qCAAA;;;;;;;;;;;wFAAiC;KAAA;;;;;;;;;;;;;;"
-}
diff --git a/packages/midnight-setup/contract-compiled/managed/midnight-setup/contract/index.d.cts b/packages/midnight-setup/contract-compiled/managed/midnight-setup/contract/index.d.cts
deleted file mode 100644
index 14f6a203c..000000000
--- a/packages/midnight-setup/contract-compiled/managed/midnight-setup/contract/index.d.cts
+++ /dev/null
@@ -1,32 +0,0 @@
-import type * as __compactRuntime from '@midnight-ntwrk/compact-runtime';
-
-export type Witnesses = {
-}
-
-export type ImpureCircuits = {
-}
-
-export type PureCircuits = {
-}
-
-export type Circuits = {
-}
-
-export type Ledger = {
- readonly message: Uint8Array;
-}
-
-export type ContractReferenceLocations = any;
-
-export declare const contractReferenceLocations : ContractReferenceLocations;
-
-export declare class Contract = Witnesses> {
- witnesses: W;
- circuits: Circuits;
- impureCircuits: ImpureCircuits;
- constructor(witnesses: W);
- initialState(context: __compactRuntime.ConstructorContext): __compactRuntime.ConstructorResult;
-}
-
-export declare function ledger(state: __compactRuntime.StateValue): Ledger;
-export declare const pureCircuits: PureCircuits;
diff --git a/packages/midnight-setup/contract-compiled/midnight-setup.compact b/packages/midnight-setup/contract-compiled/midnight-setup.compact
deleted file mode 100644
index ee012e9dc..000000000
--- a/packages/midnight-setup/contract-compiled/midnight-setup.compact
+++ /dev/null
@@ -1,9 +0,0 @@
-pragma language_version >= 0.17.0;
-
-import CompactStandardLibrary;
-
-export ledger message: Bytes<32>;
-
-constructor() {
- message = "Made with ❤️ by MeshJS team!";
-}
\ No newline at end of file
diff --git a/packages/midnight-setup/package.json b/packages/midnight-setup/package.json
index 2c7fb56ae..8c11c1eb3 100644
--- a/packages/midnight-setup/package.json
+++ b/packages/midnight-setup/package.json
@@ -1,7 +1,7 @@
{
"name": "@meshsdk/midnight-setup",
- "version": "1.9.0-beta.79",
- "description": "Midnight Network integration for MeshSDK - https://meshjs.dev/midnight",
+ "version": "1.9.0-beta.81",
+ "description": "Midnight Network integration SDK for MeshSDK - https://meshjs.dev/midnight",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
"module": "./dist/index.js",
@@ -12,22 +12,15 @@
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
- },
- "./react": {
- "types": "./dist/react.d.ts",
- "import": "./dist/react.js",
- "require": "./dist/react.cjs"
- },
- "./styles.css": "./dist/styles.css"
+ }
},
"files": [
- "dist/**",
- "contract-compiled/**"
+ "dist/**"
],
"scripts": {
- "build:mesh": "tsup src/index.ts src/react.ts --format esm,cjs --dts && cp src/react/styles.css dist/styles.css",
+ "build:mesh": "tsup src/index.ts --format esm,cjs --dts",
"clean": "rm -rf .turbo && rm -rf dist && rm -rf node_modules",
- "dev": "tsup src/index.ts src/react.ts --format esm,cjs --watch --dts",
+ "dev": "tsup src/index.ts --format esm,cjs --watch --dts",
"format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "eslint",
"pack": "npm pack --pack-destination=./dist",
@@ -35,22 +28,10 @@
},
"dependencies": {
"@midnight-ntwrk/compact-runtime": "^0.8.1",
- "@midnight-ntwrk/ledger": "^4.0.0",
"@midnight-ntwrk/midnight-js-contracts": "2.0.2",
"@midnight-ntwrk/midnight-js-types": "2.0.2",
- "@midnight-ntwrk/zswap": "4.0.0",
- "@radix-ui/react-dialog": "^1.1.14",
- "@radix-ui/react-label": "^2.1.7",
- "@radix-ui/react-progress": "^1.1.7",
- "@radix-ui/react-slot": "^1.2.3",
- "class-variance-authority": "^0.7.1",
- "clsx": "^2.1.1",
- "fp-ts": "^2.16.1",
- "lucide-react": "^0.523.0",
"pino": "^8.16.1",
- "rxjs": "^7.8.1",
- "semver": "^7.6.0",
- "tailwind-merge": "^3.3.1"
+ "rxjs": "^7.8.1"
},
"peerDependencies": {
"@midnight-ntwrk/dapp-connector-api": "^3.0.0",
@@ -58,26 +39,12 @@
"@midnight-ntwrk/midnight-js-http-client-proof-provider": "^2.0.2",
"@midnight-ntwrk/midnight-js-indexer-public-data-provider": "^2.0.2",
"@midnight-ntwrk/midnight-js-level-private-state-provider": "^2.0.2",
- "@midnight-ntwrk/midnight-js-network-id": "^2.0.2",
- "react": ">=18.0.0",
- "react-dom": ">=18.0.0"
- },
- "peerDependenciesMeta": {
- "react": {
- "optional": true
- },
- "react-dom": {
- "optional": true
- }
+ "@midnight-ntwrk/midnight-js-network-id": "^2.0.2"
},
"devDependencies": {
"@meshsdk/configs": "*",
- "@types/react": "^18.2.61",
- "@types/react-dom": "^18.2.19",
"@types/ws": "^8.5.9",
"eslint": "^8.57.0",
- "react": "^18.2.0",
- "react-dom": "^18.2.0",
"tsup": "^8.0.2",
"typescript": "^5.3.3"
},
@@ -85,7 +52,7 @@
"publishConfig": {
"access": "public"
},
- "license": "MIT",
+ "license": "Apache-2.0",
"keywords": [
"midnight",
"midnight-network",
diff --git a/packages/midnight-setup/src/common-types.ts b/packages/midnight-setup/src/common-types.ts
index f3892bf83..d074cddea 100644
--- a/packages/midnight-setup/src/common-types.ts
+++ b/packages/midnight-setup/src/common-types.ts
@@ -1,10 +1,10 @@
-import type {
- PrivateStateProvider,
- ZKConfigProvider,
- ProofProvider,
- PublicDataProvider,
- WalletProvider,
- MidnightProvider
+import type {
+ MidnightProvider,
+ PrivateStateProvider,
+ ProofProvider,
+ PublicDataProvider,
+ WalletProvider,
+ ZKConfigProvider,
} from "@midnight-ntwrk/midnight-js-types";
// Private state identifier for the contract
@@ -24,6 +24,26 @@ export interface MidnightSetupContractProviders {
midnightProvider: MidnightProvider;
}
+// Deployed contract interface
+export interface DeployedContract {
+ deployTxData: {
+ public: {
+ contractAddress: string;
+ };
+ };
+}
+
+// Contract instance type - accepts any Midnight contract
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+export type ContractInstance = any;
+
+// Contract state from public data provider
+export interface QueryContractState {
+ data: unknown;
+ blockHeight?: number | bigint;
+ blockHash?: string | Uint8Array;
+}
+
// Contract state types - using unknown for flexible state data
export interface ContractStateData {
readonly address: string;
diff --git a/packages/midnight-setup/src/index.ts b/packages/midnight-setup/src/index.ts
index 5c5f1e96d..c6414a8e6 100644
--- a/packages/midnight-setup/src/index.ts
+++ b/packages/midnight-setup/src/index.ts
@@ -1,15 +1,16 @@
-import { Observable } from "rxjs";
import { ContractAddress } from "@midnight-ntwrk/compact-runtime";
import { type Logger } from "pino";
-import { ledger, Contract } from "../contract-compiled/index.js";
-import { deployContract, findDeployedContract } from "@midnight-ntwrk/midnight-js-contracts";
-import * as utils from "./utils.js";
+import { Observable } from "rxjs";
+
import {
- MidnightSetupContractProviders,
- MidnightSetupPrivateStateId,
- DerivedMidnightSetupContractState,
+ ContractInstance,
ContractStateData,
+ DeployedContract,
+ DerivedMidnightSetupContractState,
LedgerStateData,
+ MidnightSetupContractProviders,
+ MidnightSetupPrivateStateId,
+ QueryContractState,
} from "./common-types.js";
export interface DeployedMidnightSetupAPI {
@@ -18,9 +19,6 @@ export interface DeployedMidnightSetupAPI {
getContractState: () => Promise;
getLedgerState: () => Promise;
}
-/**
- * NB: Declaring a class implements a given type, means it must contain all defined properties and methods, then take on other extra properties or class
- */
export class MidnightSetupAPI implements DeployedMidnightSetupAPI {
deployedContractAddress: string;
@@ -28,14 +26,13 @@ export class MidnightSetupAPI implements DeployedMidnightSetupAPI {
private constructor(
private providers: MidnightSetupContractProviders,
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- public readonly allReadyDeployedContract: any,
- private logger?: Logger
+ public readonly deployedContract: DeployedContract,
+ private logger?: Logger,
) {
- this.deployedContractAddress = allReadyDeployedContract.deployTxData.public.contractAddress;
+ this.deployedContractAddress =
+ deployedContract.deployTxData.public.contractAddress;
- // Real state observable
- this.state = new Observable(subscriber => {
+ this.state = new Observable((subscriber) => {
subscriber.next({
protocolTVL: [],
projects: [],
@@ -45,178 +42,210 @@ export class MidnightSetupAPI implements DeployedMidnightSetupAPI {
async getContractState(): Promise {
try {
- this.logger?.info("Getting contract state...", { address: this.deployedContractAddress });
-
- // Try to get contract state from public data provider
- const contractState = await this.providers.publicDataProvider.queryContractState(this.deployedContractAddress);
-
+ this.logger?.info("Getting contract state...", {
+ address: this.deployedContractAddress,
+ });
+
+ const contractState =
+ (await this.providers.publicDataProvider.queryContractState(
+ this.deployedContractAddress,
+ )) as QueryContractState | null;
+
if (contractState) {
this.logger?.info("Contract state retrieved successfully");
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- const stateAny = contractState as any;
return {
address: this.deployedContractAddress,
data: contractState.data,
- blockHeight: stateAny.blockHeight?.toString(),
- blockHash: stateAny.blockHash?.toString(),
+ blockHeight: contractState.blockHeight?.toString(),
+ blockHash:
+ typeof contractState.blockHash === "string"
+ ? contractState.blockHash
+ : contractState.blockHash?.toString(),
};
} else {
this.logger?.warn("No contract state found");
return {
address: this.deployedContractAddress,
data: null,
- message: "No contract state found at this address"
+ message: "No contract state found at this address",
};
}
} catch (error) {
- this.logger?.error("Failed to get contract state", { error: error instanceof Error ? error.message : error });
+ this.logger?.error("Failed to get contract state", {
+ error: error instanceof Error ? error.message : error,
+ });
return {
address: this.deployedContractAddress,
data: null,
- error: error instanceof Error ? error.message : "Failed to get contract state"
+ error:
+ error instanceof Error
+ ? error.message
+ : "Failed to get contract state",
};
}
}
async getLedgerState(): Promise {
try {
- this.logger?.info("Getting ledger state...", { address: this.deployedContractAddress });
-
+ this.logger?.info("Getting ledger state...", {
+ address: this.deployedContractAddress,
+ });
+
const contractState = await this.getContractState();
-
+
if (contractState.data) {
- // Try to parse the ledger state
try {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- const ledgerState = ledger(contractState.data as any);
+ // Generic ledger state parsing
+ const ledgerState = contractState.data as Record;
this.logger?.info("Ledger state parsed successfully");
+
+ // Parse message if it exists and is a Uint8Array
+ let messageText: string | null = null;
+ if (
+ ledgerState.message &&
+ ledgerState.message instanceof Uint8Array
+ ) {
+ messageText = new TextDecoder().decode(ledgerState.message);
+ }
+
return {
address: this.deployedContractAddress,
ledgerState: {
- message: ledgerState.message ? new TextDecoder().decode(ledgerState.message) : null,
+ message: messageText,
},
blockHeight: contractState.blockHeight,
blockHash: contractState.blockHash,
};
} catch (parseError) {
- this.logger?.warn("Failed to parse ledger state", { error: parseError });
+ this.logger?.warn("Failed to parse ledger state", {
+ error: parseError,
+ });
return {
address: this.deployedContractAddress,
rawData: contractState.data,
- parseError: parseError instanceof Error ? parseError.message : "Failed to parse ledger state"
+ parseError:
+ parseError instanceof Error
+ ? parseError.message
+ : "Failed to parse ledger state",
};
}
} else {
return {
address: this.deployedContractAddress,
- error: contractState.error || contractState.message
+ error: contractState.error || contractState.message,
};
}
} catch (error) {
- this.logger?.error("Failed to get ledger state", { error: error instanceof Error ? error.message : error });
+ this.logger?.error("Failed to get ledger state", {
+ error: error instanceof Error ? error.message : error,
+ });
return {
address: this.deployedContractAddress,
- error: error instanceof Error ? error.message : "Failed to get ledger state"
+ error:
+ error instanceof Error ? error.message : "Failed to get ledger state",
};
}
}
- static async deployMidnightSetupContract(
+ static async deployContract(
providers: MidnightSetupContractProviders,
- logger?: Logger
+ contractInstance: ContractInstance,
+ logger?: Logger,
): Promise {
logger?.info("Deploying contract...");
-
+
try {
- // Get or create initial private state
- const initialPrivateState = await MidnightSetupAPI.getPrivateState(providers);
-
- // Create contract instance with constructor arguments
- const contractInstance = new Contract({});
-
- // Real contract deployment using the wallet
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- const deployedContract = await deployContract(
- providers as any,
- {
- contract: contractInstance,
- initialPrivateState: initialPrivateState,
- privateStateId: MidnightSetupPrivateStateId,
- }
+ const initialPrivateState =
+ await MidnightSetupAPI.getPrivateState(providers);
+
+ const { deployContract } = await import(
+ "@midnight-ntwrk/midnight-js-contracts"
);
- logger?.info("Contract deployed successfully", {
- address: deployedContract.deployTxData.public.contractAddress
+ const deployedContract = (await deployContract(providers, {
+ contract: contractInstance,
+ initialPrivateState: initialPrivateState,
+ privateStateId: MidnightSetupPrivateStateId,
+ })) as DeployedContract;
+
+ logger?.info("Contract deployed successfully", {
+ address: deployedContract.deployTxData.public.contractAddress,
});
return new MidnightSetupAPI(providers, deployedContract, logger);
} catch (error) {
- logger?.error("Failed to deploy contract", {
+ logger?.error("Failed to deploy contract", {
error: error instanceof Error ? error.message : String(error),
- stack: error instanceof Error ? error.stack : undefined
+ stack: error instanceof Error ? error.stack : undefined,
});
throw error;
}
}
- static async joinMidnightSetupContract(
+ static async joinContract(
providers: MidnightSetupContractProviders,
+ contractInstance: ContractInstance,
contractAddress: string,
- logger?: Logger
+ logger?: Logger,
): Promise {
logger?.info("Joining contract...", { contractAddress });
-
+
try {
- // Get or create initial private state
- const initialPrivateState = await MidnightSetupAPI.getPrivateState(providers);
-
- // Create contract instance
- const contractInstance = new Contract({});
-
- // Real contract join using the wallet
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- const existingContract = await findDeployedContract(
- providers as any,
- {
- contract: contractInstance,
- contractAddress: contractAddress,
- privateStateId: MidnightSetupPrivateStateId,
- initialPrivateState: initialPrivateState,
- }
+ const initialPrivateState =
+ await MidnightSetupAPI.getPrivateState(providers);
+
+ const { findDeployedContract } = await import(
+ "@midnight-ntwrk/midnight-js-contracts"
);
- logger?.info("Successfully joined contract", {
- address: existingContract.deployTxData.public.contractAddress
+ const existingContract = (await findDeployedContract(providers, {
+ contract: contractInstance,
+ contractAddress: contractAddress,
+ privateStateId: MidnightSetupPrivateStateId,
+ initialPrivateState: initialPrivateState,
+ })) as DeployedContract;
+
+ logger?.info("Successfully joined contract", {
+ address: existingContract.deployTxData.public.contractAddress,
});
return new MidnightSetupAPI(providers, existingContract, logger);
} catch (error) {
- logger?.error("Failed to join contract", {
+ logger?.error("Failed to join contract", {
error: error instanceof Error ? error.message : String(error),
- contractAddress
+ contractAddress,
});
throw error;
}
}
private static async getPrivateState(
- providers: MidnightSetupContractProviders
+ providers: MidnightSetupContractProviders,
): Promise> {
try {
const existingPrivateState = await providers.privateStateProvider.get(
- MidnightSetupPrivateStateId
+ MidnightSetupPrivateStateId,
);
-
- // If no existing state, return empty object (the contract will initialize it)
+
return existingPrivateState ?? {};
} catch (error) {
- console.warn("Error getting private state, returning empty object:", error);
+ console.warn(
+ "Error getting private state, returning empty object:",
+ error,
+ );
return {};
}
}
}
export * as utils from "./utils.js";
-
export * from "./common-types.js";
-// Re-export types for external use
-export type { ContractStateData, LedgerStateData } from "./common-types.js";
+// Re-export main types for convenience
+export type {
+ ContractStateData,
+ LedgerStateData,
+ DeployedContract,
+ ContractInstance,
+ QueryContractState,
+ MidnightSetupContractProviders,
+ TokenCircuitKeys,
+} from "./common-types.js";
diff --git a/packages/midnight-setup/src/react.ts b/packages/midnight-setup/src/react.ts
deleted file mode 100644
index 410ffa27f..000000000
--- a/packages/midnight-setup/src/react.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-// React hooks and providers for Midnight Network
-export { default as MidnightWalletProvider, MidnightWalletContext } from "./react/providers/MidnightWalletProvider";
-export type { MidnightWalletState, MidnightWalletContextType } from "./react/providers/MidnightWalletProvider";
-
-export { default as DeployedContractProvider } from "./react/providers/DeployedContractProvider";
-
-export { default as useMidnightWallet } from "./react/hooks/useMidnightWallet";
-
-// UI Components
-export { Badge } from "./react/components/badge";
-export { Button } from "./react/components/button";
-export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent } from "./react/components/card";
-export { Dialog, DialogPortal, DialogOverlay, DialogTrigger, DialogClose, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription } from "./react/components/dialog";
-export { Input } from "./react/components/input";
-export { Label } from "./react/components/label";
-export { Progress } from "./react/components/progress";
-export { Textarea } from "./react/components/textarea";
-
-// Utils
-export * from "./react/common-types";
-export * from "./react/utils";
-export * from "./react/actions";
-
diff --git a/packages/midnight-setup/src/react/actions.ts b/packages/midnight-setup/src/react/actions.ts
deleted file mode 100644
index ecd13a2c8..000000000
--- a/packages/midnight-setup/src/react/actions.ts
+++ /dev/null
@@ -1,226 +0,0 @@
-import { type ContractAddress } from "@midnight-ntwrk/compact-runtime";
-import {
- concatMap,
- filter,
- firstValueFrom,
- interval,
- map,
- of,
- take,
- tap,
- throwError,
- timeout,
- catchError,
-} from "rxjs";
-import { pipe as fnPipe } from "fp-ts/function";
-import {
- type DAppConnectorAPI,
- type DAppConnectorWalletAPI,
- type ServiceUriConfig,
-} from "@midnight-ntwrk/dapp-connector-api";
-import { levelPrivateStateProvider } from "@midnight-ntwrk/midnight-js-level-private-state-provider";
-import { FetchZkConfigProvider } from "@midnight-ntwrk/midnight-js-fetch-zk-config-provider";
-import { httpClientProofProvider } from "@midnight-ntwrk/midnight-js-http-client-proof-provider";
-import { indexerPublicDataProvider } from "@midnight-ntwrk/midnight-js-indexer-public-data-provider";
-import {
- type BalancedTransaction,
- type UnbalancedTransaction,
- createBalancedTx,
-} from "@midnight-ntwrk/midnight-js-types";
-import {
- type CoinInfo,
- Transaction,
- type TransactionId,
-} from "@midnight-ntwrk/ledger";
-import { Transaction as ZswapTransaction } from "@midnight-ntwrk/zswap";
-import * as semver from "semver";
-import {
- getLedgerNetworkId,
- getZswapNetworkId,
-} from "@midnight-ntwrk/midnight-js-network-id";
-import {
- MidnightSetupAPI,
- type MidnightSetupContractProviders,
- type DeployedMidnightSetupAPI,
- type TokenCircuitKeys,
-} from "../index";
-import type { WalletAndProvider } from "./common-types";
-import type { Logger } from "pino";
-
-const connectWallet = async (): Promise<{
- wallet: DAppConnectorWalletAPI;
- uris: ServiceUriConfig;
-}> => {
- const COMPATIBLE_CONNECTOR_API_VERSION = "1.x";
- return firstValueFrom(
- fnPipe(
- interval(100),
- map(() => window.midnight?.mnLace),
- tap((connectorAPI) => {
- console.info(connectorAPI, "Check for wallet connector API");
- }),
- filter(
- (connectorAPI): connectorAPI is DAppConnectorAPI => !!connectorAPI
- ),
- concatMap((connectorAPI) =>
- semver.satisfies(
- connectorAPI.apiVersion,
- COMPATIBLE_CONNECTOR_API_VERSION
- )
- ? of(connectorAPI)
- : throwError(() => {
- console.error(
- {
- expected: COMPATIBLE_CONNECTOR_API_VERSION,
- actual: connectorAPI.apiVersion,
- },
- "Incompatible version of wallet connector API"
- );
-
- return new Error(
- `Incompatible version of Midnight Lace wallet found. Require '${COMPATIBLE_CONNECTOR_API_VERSION}', got '${connectorAPI.apiVersion}'.`
- );
- })
- ),
- tap((connectorAPI) => {
- console.info(
- connectorAPI,
- "Compatible wallet connector API found. Connecting."
- );
- }),
- take(1),
- timeout({
- first: 1_000,
- with: () =>
- throwError(() => {
- console.error("Could not find wallet connector API");
-
- return new Error(
- "Could not find Midnight Lace wallet. Extension installed?"
- );
- }),
- }),
- concatMap(async (connectorAPI) => {
- const isEnabled = await connectorAPI.isEnabled();
-
- console.info(isEnabled, "Wallet connector API enabled status");
-
- return connectorAPI;
- }),
- timeout({
- first: 5_000,
- with: () =>
- throwError(() => {
- console.error("Wallet connector API has failed to respond");
-
- return new Error(
- "Midnight Lace wallet has failed to respond. Extension enabled?"
- );
- }),
- }),
- concatMap(async (connectorAPI) => ({
- walletConnectorAPI: await connectorAPI.enable(),
- connectorAPI,
- })),
- catchError((error, apis) =>
- error
- ? throwError(() => {
- console.error("Unable to enable connector API");
- return new Error("Application is not authorized");
- })
- : apis
- ),
- concatMap(async ({ walletConnectorAPI, connectorAPI }) => {
- const uris = await connectorAPI.serviceUriConfig();
-
- console.info(
- "Connected to wallet connector API and retrieved service configuration"
- );
-
- return { wallet: walletConnectorAPI, uris };
- })
- )
- );
-};
-
-export const initialWalletAndProviders =
- async (): Promise => {
- const { wallet, uris } = await connectWallet();
- const walletState = await wallet.state();
-
- const providers = {
- privateStateProvider: levelPrivateStateProvider({
- privateStateStoreName: "midnight-setup-private-state",
- }),
- zkConfigProvider: new FetchZkConfigProvider(
- window.location.origin,
- fetch.bind(window)
- ),
- proofProvider: httpClientProofProvider(uris.proverServerUri),
- publicDataProvider: indexerPublicDataProvider(
- uris.indexerUri,
- uris.indexerWsUri
- ),
- walletProvider: {
- coinPublicKey: walletState.coinPublicKey,
- encryptionPublicKey: walletState.encryptionPublicKey,
- balanceTx(
- tx: UnbalancedTransaction,
- newCoins: CoinInfo[]
- ): Promise {
- return wallet
- .balanceAndProveTransaction(
- ZswapTransaction.deserialize(
- tx.serialize(getLedgerNetworkId()),
- getZswapNetworkId()
- ),
- newCoins
- )
- .then((zswapTx) =>
- Transaction.deserialize(
- zswapTx.serialize(getZswapNetworkId()),
- getLedgerNetworkId()
- )
- )
- .then(createBalancedTx)
- .finally(() => {
- console.log("balanceTxDone");
- });
- },
- },
- midnightProvider: {
- submitTx(tx: BalancedTransaction): Promise {
- return wallet.submitTransaction(tx);
- },
- },
- };
-
- return { wallet, uris, providers };
- };
-
-export const resolve = async (
- providers: MidnightSetupContractProviders,
- logger: Logger,
- contractAddress?: ContractAddress
-): Promise => {
- let api;
- if (contractAddress) {
- api = await MidnightSetupAPI.joinMidnightSetupContract(
- providers,
- contractAddress
- );
- } else {
- api = await MidnightSetupAPI.deployMidnightSetupContract(providers, logger);
- }
-
- return api;
-};
-
-export const calculateExpiryDate = (duration: number, creationDate: number) => {
- const millisecondsPerHour = 1000 * 60 * 60 * 24;
- const durationInMilliseconds = millisecondsPerHour * duration;
- const expiryDate = creationDate + durationInMilliseconds;
-
- const dateObject = new Date(expiryDate);
- return dateObject.toLocaleDateString();
-};
diff --git a/packages/midnight-setup/src/react/common-types.ts b/packages/midnight-setup/src/react/common-types.ts
deleted file mode 100644
index 7ad765ebf..000000000
--- a/packages/midnight-setup/src/react/common-types.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import type { MidnightSetupContractProviders, DeployedMidnightSetupAPI } from "../index";
-import type { DAppConnectorWalletAPI, ServiceUriConfig } from "@midnight-ntwrk/dapp-connector-api";
-
-
-export interface WalletAndProvider{
- readonly wallet: DAppConnectorWalletAPI,
- readonly uris: ServiceUriConfig,
- readonly providers: MidnightSetupContractProviders
-}
-
-export interface WalletAPI {
- wallet: DAppConnectorWalletAPI;
- coinPublicKey: string;
- encryptionPublicKey: string;
- uris: ServiceUriConfig;
-}
-
-
-export interface MidnightSetupDeployment{
- status: "inprogress" | "deployed" | "failed",
- api: DeployedMidnightSetupAPI;
-}
\ No newline at end of file
diff --git a/packages/midnight-setup/src/react/components/badge.tsx b/packages/midnight-setup/src/react/components/badge.tsx
deleted file mode 100644
index 0f7d665e1..000000000
--- a/packages/midnight-setup/src/react/components/badge.tsx
+++ /dev/null
@@ -1,46 +0,0 @@
-import * as React from "react"
-import { Slot } from "@radix-ui/react-slot"
-import { cva, type VariantProps } from "class-variance-authority"
-
-import { cn } from "../utils"
-
-const badgeVariants = cva(
- "inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",
- {
- variants: {
- variant: {
- default:
- "border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
- secondary:
- "border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
- destructive:
- "border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
- outline:
- "text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
- },
- },
- defaultVariants: {
- variant: "default",
- },
- }
-)
-
-function Badge({
- className,
- variant,
- asChild = false,
- ...props
-}: React.ComponentProps<"span"> &
- VariantProps & { asChild?: boolean }) {
- const Comp = asChild ? Slot : "span"
-
- return (
-
- )
-}
-
-export { Badge, badgeVariants }
diff --git a/packages/midnight-setup/src/react/components/button.tsx b/packages/midnight-setup/src/react/components/button.tsx
deleted file mode 100644
index 6739b80b7..000000000
--- a/packages/midnight-setup/src/react/components/button.tsx
+++ /dev/null
@@ -1,59 +0,0 @@
-import * as React from "react"
-import { Slot } from "@radix-ui/react-slot"
-import { cva, type VariantProps } from "class-variance-authority"
-
-import { cn } from "../utils"
-
-const buttonVariants = cva(
- "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
- {
- variants: {
- variant: {
- default:
- "bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",
- destructive:
- "bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
- outline:
- "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
- secondary:
- "bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",
- ghost:
- "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
- link: "text-primary underline-offset-4 hover:underline",
- },
- size: {
- default: "h-9 px-4 py-2 has-[>svg]:px-3",
- sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
- lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
- icon: "size-9",
- },
- },
- defaultVariants: {
- variant: "default",
- size: "default",
- },
- }
-)
-
-function Button({
- className,
- variant,
- size,
- asChild = false,
- ...props
-}: React.ComponentProps<"button"> &
- VariantProps & {
- asChild?: boolean
- }) {
- const Comp = asChild ? Slot : "button"
-
- return (
-
- )
-}
-
-export { Button, buttonVariants }
diff --git a/packages/midnight-setup/src/react/components/card.tsx b/packages/midnight-setup/src/react/components/card.tsx
deleted file mode 100644
index fa6134e40..000000000
--- a/packages/midnight-setup/src/react/components/card.tsx
+++ /dev/null
@@ -1,92 +0,0 @@
-import * as React from "react"
-
-import { cn } from "../utils"
-
-function Card({ className, ...props }: React.ComponentProps<"div">) {
- return (
-
- )
-}
-
-function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
- return (
-
- )
-}
-
-function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
- return (
-
- )
-}
-
-function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
- return (
-
- )
-}
-
-function CardAction({ className, ...props }: React.ComponentProps<"div">) {
- return (
-
- )
-}
-
-function CardContent({ className, ...props }: React.ComponentProps<"div">) {
- return (
-
- )
-}
-
-function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
- return (
-
- )
-}
-
-export {
- Card,
- CardHeader,
- CardFooter,
- CardTitle,
- CardAction,
- CardDescription,
- CardContent,
-}
diff --git a/packages/midnight-setup/src/react/components/dialog.tsx b/packages/midnight-setup/src/react/components/dialog.tsx
deleted file mode 100644
index 8805130ae..000000000
--- a/packages/midnight-setup/src/react/components/dialog.tsx
+++ /dev/null
@@ -1,141 +0,0 @@
-import * as React from "react"
-import * as DialogPrimitive from "@radix-ui/react-dialog"
-import { XIcon } from "lucide-react"
-
-import { cn } from "../utils"
-
-function Dialog({
- ...props
-}: React.ComponentProps) {
- return
-}
-
-function DialogTrigger({
- ...props
-}: React.ComponentProps) {
- return
-}
-
-function DialogPortal({
- ...props
-}: React.ComponentProps) {
- return
-}
-
-function DialogClose({
- ...props
-}: React.ComponentProps) {
- return
-}
-
-function DialogOverlay({
- className,
- ...props
-}: React.ComponentProps) {
- return (
-
- )
-}
-
-function DialogContent({
- className,
- children,
- showCloseButton = true,
- ...props
-}: React.ComponentProps & {
- showCloseButton?: boolean
-}) {
- return (
-
-
-
- {children}
- {showCloseButton && (
-
-
- Close
-
- )}
-
-
- )
-}
-
-function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
- return (
-
- )
-}
-
-function DialogFooter({ className, ...props }: React.ComponentProps<"div">) {
- return (
-
- )
-}
-
-function DialogTitle({
- className,
- ...props
-}: React.ComponentProps) {
- return (
-
- )
-}
-
-function DialogDescription({
- className,
- ...props
-}: React.ComponentProps) {
- return (
-
- )
-}
-
-export {
- Dialog,
- DialogClose,
- DialogContent,
- DialogDescription,
- DialogFooter,
- DialogHeader,
- DialogOverlay,
- DialogPortal,
- DialogTitle,
- DialogTrigger,
-}
diff --git a/packages/midnight-setup/src/react/components/input.tsx b/packages/midnight-setup/src/react/components/input.tsx
deleted file mode 100644
index 5cfce2051..000000000
--- a/packages/midnight-setup/src/react/components/input.tsx
+++ /dev/null
@@ -1,21 +0,0 @@
-import * as React from "react"
-
-import { cn } from "../utils"
-
-function Input({ className, type, ...props }: React.ComponentProps<"input">) {
- return (
-
- )
-}
-
-export { Input }
diff --git a/packages/midnight-setup/src/react/components/label.tsx b/packages/midnight-setup/src/react/components/label.tsx
deleted file mode 100644
index 6717e34ef..000000000
--- a/packages/midnight-setup/src/react/components/label.tsx
+++ /dev/null
@@ -1,22 +0,0 @@
-import * as React from "react"
-import * as LabelPrimitive from "@radix-ui/react-label"
-
-import { cn } from "../utils"
-
-function Label({
- className,
- ...props
-}: React.ComponentProps) {
- return (
-
- )
-}
-
-export { Label }
diff --git a/packages/midnight-setup/src/react/components/progress.tsx b/packages/midnight-setup/src/react/components/progress.tsx
deleted file mode 100644
index b622ce8ab..000000000
--- a/packages/midnight-setup/src/react/components/progress.tsx
+++ /dev/null
@@ -1,31 +0,0 @@
-"use client"
-
-import * as React from "react"
-import * as ProgressPrimitive from "@radix-ui/react-progress"
-
-import { cn } from "../utils"
-
-function Progress({
- className,
- value,
- ...props
-}: React.ComponentProps) {
- return (
-
-
-
- )
-}
-
-export { Progress }
diff --git a/packages/midnight-setup/src/react/components/textarea.tsx b/packages/midnight-setup/src/react/components/textarea.tsx
deleted file mode 100644
index 9353ed364..000000000
--- a/packages/midnight-setup/src/react/components/textarea.tsx
+++ /dev/null
@@ -1,18 +0,0 @@
-import * as React from "react"
-
-import { cn } from "../utils"
-
-function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
- return (
-
- )
-}
-
-export { Textarea }
diff --git a/packages/midnight-setup/src/react/hooks/useMidnightWallet.tsx b/packages/midnight-setup/src/react/hooks/useMidnightWallet.tsx
deleted file mode 100644
index cf781da83..000000000
--- a/packages/midnight-setup/src/react/hooks/useMidnightWallet.tsx
+++ /dev/null
@@ -1,12 +0,0 @@
-import { MidnightWalletContext } from '../providers/MidnightWalletProvider'
-import { useContext } from 'react'
-
-export const useMidnightWallet = () => {
- const context = useContext(MidnightWalletContext)
- if(!context){
- return;
- }
- return context;
-}
-
-export default useMidnightWallet
\ No newline at end of file
diff --git a/packages/midnight-setup/src/react/polyfills.ts b/packages/midnight-setup/src/react/polyfills.ts
deleted file mode 100644
index ad66ba461..000000000
--- a/packages/midnight-setup/src/react/polyfills.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-// src/polyfills.ts - Create this file
-import { Buffer } from 'buffer'
-
-// Make Buffer available globally
-window.Buffer = Buffer
-window.global = window.global || window
-window.process = window.process || { env: {} }
-
-// Export for direct imports
-export { Buffer }
\ No newline at end of file
diff --git a/packages/midnight-setup/src/react/providers/DeployedContractProvider.tsx b/packages/midnight-setup/src/react/providers/DeployedContractProvider.tsx
deleted file mode 100644
index 69b18bd0c..000000000
--- a/packages/midnight-setup/src/react/providers/DeployedContractProvider.tsx
+++ /dev/null
@@ -1,160 +0,0 @@
-import useMidnightWallet from "../hooks/useMidnightWallet";
-import { MidnightSetupAPI, type DeployedMidnightSetupAPI } from "../../index";
-import type { Logger } from "pino";
-import {
- createContext,
- useCallback,
- useContext,
- useState,
- type PropsWithChildren,
-} from "react";
-
-export interface DeploymentProvider {
- readonly isJoining: boolean;
- readonly isDeploying: boolean;
- readonly error: string | null;
- readonly hasJoined: boolean;
- readonly hasDeployed: boolean;
- readonly midnightSetupApi: DeployedMidnightSetupAPI | undefined;
- readonly deployedContractAddress: string | undefined;
- onJoinContract: (address: string) => Promise;
- onDeployContract: () => Promise;
- clearError: () => void;
-}
-
-export const DeployedContractContext = createContext(null);
-
-interface DeployedContractProviderProps extends PropsWithChildren {
- logger?: Logger;
-}
-
-const DeployedContractProvider = ({
- children,
- logger
-}: DeployedContractProviderProps) => {
-
- const [midnightSetupApi, setMidnightSetupApi] = useState(undefined);
- const [isJoining, setIsJoining] = useState(false);
- const [isDeploying, setIsDeploying] = useState(false);
- const [error, setError] = useState(null);
- const [hasJoined, setHasJoined] = useState(false);
- const [hasDeployed, setHasDeployed] = useState(false);
- const [deployedContractAddress, setDeployedContractAddress] = useState(undefined);
-
- // Use the custom hook instead of useContext directly
- const walletContext = useMidnightWallet();
-
- const onJoinContract = useCallback(async (address: string) => {
- // Prevent multiple simultaneous joins
- if (isJoining || hasJoined || isDeploying || hasDeployed) return;
-
- // Validate requirements
- if (!walletContext?.walletState.hasConnected || !walletContext?.walletState.providers) {
- setError("Wallet must be connected before joining contract");
- return;
- }
-
- if (!address) {
- setError("Contract address is required");
- return;
- }
-
- setIsJoining(true);
- setError(null);
-
- try {
- const deployedAPI = await MidnightSetupAPI.joinMidnightSetupContract(
- walletContext.walletState.providers,
- address,
- logger
- );
-
- setMidnightSetupApi(deployedAPI);
- setHasJoined(true);
- setDeployedContractAddress(deployedAPI.deployedContractAddress);
- logger?.info("Successfully joined contract", { contractAddress: address });
-
- } catch (error) {
- const errMsg = error instanceof Error
- ? error.message
- : `Failed to join contract at ${address}`;
- setError(errMsg);
- logger?.error("Failed to join contract", { error: errMsg, contractAddress: address });
- } finally {
- setIsJoining(false);
- }
- }, [isJoining, hasJoined, isDeploying, hasDeployed, walletContext?.walletState.hasConnected, walletContext?.walletState.providers, logger]);
-
- const onDeployContract = useCallback(async () => {
- // Prevent multiple simultaneous operations
- if (isDeploying || hasDeployed || isJoining || hasJoined) return;
-
- // Validate requirements
- if (!walletContext?.walletState.hasConnected || !walletContext?.walletState.providers) {
- setError("Wallet must be connected before deploying contract");
- return;
- }
-
- setIsDeploying(true);
- setError(null);
-
- try {
- const deployedAPI = await MidnightSetupAPI.deployMidnightSetupContract(
- walletContext.walletState.providers,
- logger
- );
-
- setMidnightSetupApi(deployedAPI);
- setHasDeployed(true);
- setDeployedContractAddress(deployedAPI.deployedContractAddress);
- logger?.info("Successfully deployed new contract", {
- contractAddress: deployedAPI.deployedContractAddress
- });
-
- } catch (error) {
- const errMsg = error instanceof Error
- ? error.message
- : "Failed to deploy new contract";
- setError(errMsg);
- logger?.error("Failed to deploy contract", { error: errMsg });
- } finally {
- setIsDeploying(false);
- }
- }, [isDeploying, hasDeployed, isJoining, hasJoined, walletContext?.walletState.hasConnected, walletContext?.walletState.providers, logger]);
-
- const clearError = useCallback(() => {
- setError(null);
- }, []);
-
- const contextValue: DeploymentProvider = {
- isJoining,
- isDeploying,
- hasJoined,
- hasDeployed,
- error,
- midnightSetupApi,
- deployedContractAddress,
- onJoinContract,
- onDeployContract,
- clearError,
- };
-
- return (
-
- {children}
-
- );
-};
-
-// Custom hook for consuming the context
-export const useDeployedContract = (): DeploymentProvider => {
- const context = useContext(DeployedContractContext);
-
- if (!context) {
- throw new Error("useDeployedContract must be used within a DeployedContractProvider");
- }
-
- return context;
-};
-
-export default DeployedContractProvider;
\ No newline at end of file
diff --git a/packages/midnight-setup/src/react/providers/MidnightWalletProvider.tsx b/packages/midnight-setup/src/react/providers/MidnightWalletProvider.tsx
deleted file mode 100644
index ab0275b0b..000000000
--- a/packages/midnight-setup/src/react/providers/MidnightWalletProvider.tsx
+++ /dev/null
@@ -1,173 +0,0 @@
-import { initialWalletAndProviders } from "../actions";
-import type { WalletAPI } from "../common-types";
-import type { MidnightSetupContractProviders } from "../../common-types";
-import type { Logger } from "pino";
-import {
- createContext,
- useReducer,
- useCallback,
- type PropsWithChildren,
-} from "react";
-
-export interface MidnightWalletState {
- readonly address: string | undefined;
- readonly isConnecting: boolean;
- readonly coinPublicKey: string | undefined;
- readonly providers: MidnightSetupContractProviders | undefined;
- readonly walletAPI: WalletAPI | undefined;
- readonly hasConnected: boolean;
- readonly error: string | null;
-}
-
-export interface MidnightWalletContextType {
- walletState: MidnightWalletState;
- connectToWalletAndInitializeProviders: () => Promise;
- disconnect: () => void;
- clearError: () => void;
-}
-
-// Initial state
-const initialState: MidnightWalletState = {
- address: undefined,
- isConnecting: false,
- coinPublicKey: undefined,
- providers: undefined,
- walletAPI: undefined,
- hasConnected: false,
- error: null,
-};
-
-// Action types
-type WalletAction =
- | { type: "CONNECT_START" }
- | {
- type: "CONNECT_SUCCESS";
- payload: Omit<
- MidnightWalletState,
- "isConnecting" | "hasConnected" | "error"
- >;
- }
- | { type: "CONNECT_ERROR"; payload: string }
- | { type: "DISCONNECT" }
- | { type: "CLEAR_ERROR" };
-
-// Reducer
-function walletReducer(
- state: MidnightWalletState,
- action: WalletAction
-): MidnightWalletState {
- switch (action.type) {
- case "CONNECT_START":
- return {
- ...state,
- isConnecting: true,
- error: null,
- };
- case "CONNECT_SUCCESS":
- return {
- ...state,
- ...action.payload,
- isConnecting: false,
- hasConnected: true,
- error: null,
- };
- case "CONNECT_ERROR":
- return {
- ...state,
- isConnecting: false,
- error: action.payload,
- };
- case "DISCONNECT":
- return {
- ...initialState,
- hasConnected: false,
- };
- case "CLEAR_ERROR":
- return {
- ...state,
- error: null,
- };
- default:
- return state;
- }
-}
-
-// Context
-export const MidnightWalletContext =
- createContext(null);
-
-// Provider Props
-interface MidnightWalletProviderProps extends PropsWithChildren {
- logger?: Logger;
-}
-
-const MidnightWalletProvider = ({
- children,
- logger,
-}: MidnightWalletProviderProps) => {
- const [walletState, dispatch] = useReducer(walletReducer, initialState);
-
- const connectToWalletAndInitializeProviders = useCallback(async () => {
- if (walletState.isConnecting) return; // Prevent multiple simultaneous connections
-
- dispatch({ type: "CONNECT_START" });
-
- try {
- const { wallet, uris, providers } = await initialWalletAndProviders();
-
- if (!wallet) {
- throw new Error("Failed to initialize wallet");
- }
-
- const walletStateData = await wallet.state();
-
- dispatch({
- type: "CONNECT_SUCCESS",
- payload: {
- address: walletStateData.address,
- coinPublicKey: walletStateData.coinPublicKey,
- providers,
- walletAPI: {
- wallet,
- uris,
- coinPublicKey: walletStateData.coinPublicKey,
- encryptionPublicKey: walletStateData.encryptionPublicKey,
- },
- },
- });
-
- logger?.info("Wallet connected successfully", {
- address: walletStateData.address,
- });
- } catch (error) {
- const errorMessage =
- error instanceof Error ? error.message : "Failed to initialize wallet";
- dispatch({ type: "CONNECT_ERROR", payload: errorMessage });
- logger?.error("Wallet connection failed", { error: errorMessage });
- }
- }, [walletState.isConnecting, logger]);
-
- const disconnect = useCallback(() => {
- dispatch({ type: "DISCONNECT" });
- logger?.info("Wallet disconnected");
- }, [logger]);
-
- const clearError = useCallback(() => {
- dispatch({ type: "CLEAR_ERROR" });
- }, []);
-
- const contextValue: MidnightWalletContextType = {
- walletState,
- connectToWalletAndInitializeProviders,
- disconnect,
- clearError,
- };
-
- return (
-
- {children}
-
- );
-};
-
-export default MidnightWalletProvider;
diff --git a/packages/midnight-setup/src/react/styles.css b/packages/midnight-setup/src/react/styles.css
deleted file mode 100644
index 5a7873abc..000000000
--- a/packages/midnight-setup/src/react/styles.css
+++ /dev/null
@@ -1,2 +0,0 @@
-@import "tailwindcss";
-@import "tw-animate-css";
diff --git a/packages/midnight-setup/src/react/utils.ts b/packages/midnight-setup/src/react/utils.ts
deleted file mode 100644
index bd0c391dd..000000000
--- a/packages/midnight-setup/src/react/utils.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { clsx, type ClassValue } from "clsx"
-import { twMerge } from "tailwind-merge"
-
-export function cn(...inputs: ClassValue[]) {
- return twMerge(clsx(inputs))
-}
diff --git a/packages/midnight-setup/tsconfig.json b/packages/midnight-setup/tsconfig.json
index 36e3eea69..ab5de2912 100644
--- a/packages/midnight-setup/tsconfig.json
+++ b/packages/midnight-setup/tsconfig.json
@@ -8,16 +8,14 @@
"sourceMap": true,
"module": "ES2022",
"target": "ES2022",
- "lib": ["ES2022", "DOM"],
+ "lib": ["ES2022"],
"moduleResolution": "node",
"esModuleInterop": true,
"skipLibCheck": true,
"strict": true,
"resolveJsonModule": true,
- "allowSyntheticDefaultImports": true,
- "jsx": "react-jsx"
+ "allowSyntheticDefaultImports": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "**/*.test.ts"]
}
-
diff --git a/packages/midnight-setup/tsup.config.ts b/packages/midnight-setup/tsup.config.ts
index e66679765..a914f7156 100644
--- a/packages/midnight-setup/tsup.config.ts
+++ b/packages/midnight-setup/tsup.config.ts
@@ -1,7 +1,7 @@
import { defineConfig } from "tsup";
export default defineConfig({
- entry: ["src/index.ts", "src/react.ts"],
+ entry: ["src/index.ts"],
format: ["esm", "cjs"],
dts: true,
splitting: false,
@@ -11,31 +11,15 @@ export default defineConfig({
cjsInterop: true,
external: [
"@midnight-ntwrk/compact-runtime",
- "@midnight-ntwrk/ledger",
"@midnight-ntwrk/midnight-js-contracts",
"@midnight-ntwrk/midnight-js-types",
- "@midnight-ntwrk/midnight-js-network-id",
- "@midnight-ntwrk/zswap",
"@midnight-ntwrk/dapp-connector-api",
"@midnight-ntwrk/midnight-js-fetch-zk-config-provider",
"@midnight-ntwrk/midnight-js-http-client-proof-provider",
"@midnight-ntwrk/midnight-js-indexer-public-data-provider",
"@midnight-ntwrk/midnight-js-level-private-state-provider",
- "fp-ts",
+ "@midnight-ntwrk/midnight-js-network-id",
"pino",
- "rxjs",
- "semver",
- "react",
- "react-dom",
- "react/jsx-runtime",
- "@radix-ui/react-dialog",
- "@radix-ui/react-label",
- "@radix-ui/react-progress",
- "@radix-ui/react-slot",
- "lucide-react",
- "class-variance-authority",
- "clsx",
- "tailwind-merge"
+ "rxjs"
],
});
-
diff --git a/packages/midnight-setup/ui/.gitignore b/packages/midnight-setup/ui/.gitignore
deleted file mode 100644
index fc5ae9f0c..000000000
--- a/packages/midnight-setup/ui/.gitignore
+++ /dev/null
@@ -1,25 +0,0 @@
-# Logs
-logs
-*.log
-npm-debug.log*
-yarn-debug.log*
-yarn-error.log*
-pnpm-debug.log*
-lerna-debug.log*
-
-node_modules
-dist
-dist-ssr
-*.local
-
-# Editor directories and files
-.vscode/*
-!.vscode/extensions.json
-.idea
-.DS_Store
-*.suo
-*.ntvs*
-*.njsproj
-*.sln
-*.sw?
-.vercel
diff --git a/packages/midnight-setup/ui/components.json b/packages/midnight-setup/ui/components.json
deleted file mode 100644
index 73afbdbcc..000000000
--- a/packages/midnight-setup/ui/components.json
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "$schema": "https://ui.shadcn.com/schema.json",
- "style": "new-york",
- "rsc": false,
- "tsx": true,
- "tailwind": {
- "config": "",
- "css": "src/index.css",
- "baseColor": "neutral",
- "cssVariables": true,
- "prefix": ""
- },
- "aliases": {
- "components": "@/components",
- "utils": "@/lib/utils",
- "ui": "@/components/ui",
- "lib": "@/lib",
- "hooks": "@/hooks"
- },
- "iconLibrary": "lucide"
-}
\ No newline at end of file
diff --git a/packages/midnight-setup/ui/eslint.config.js b/packages/midnight-setup/ui/eslint.config.js
deleted file mode 100644
index d94e7deb7..000000000
--- a/packages/midnight-setup/ui/eslint.config.js
+++ /dev/null
@@ -1,23 +0,0 @@
-import js from '@eslint/js'
-import globals from 'globals'
-import reactHooks from 'eslint-plugin-react-hooks'
-import reactRefresh from 'eslint-plugin-react-refresh'
-import tseslint from 'typescript-eslint'
-import { globalIgnores } from 'eslint/config'
-
-export default tseslint.config([
- globalIgnores(['dist']),
- {
- files: ['**/*.{ts,tsx}'],
- extends: [
- js.configs.recommended,
- tseslint.configs.recommended,
- reactHooks.configs['recommended-latest'],
- reactRefresh.configs.vite,
- ],
- languageOptions: {
- ecmaVersion: 2020,
- globals: globals.browser,
- },
- },
-])
diff --git a/packages/midnight-setup/ui/index.html b/packages/midnight-setup/ui/index.html
deleted file mode 100644
index 54c8470f9..000000000
--- a/packages/midnight-setup/ui/index.html
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
- Midnight Setup | Powered by MeshJS
-
-
-
-
-
-
diff --git a/packages/midnight-setup/ui/package.json b/packages/midnight-setup/ui/package.json
deleted file mode 100644
index 7c5dd5dd7..000000000
--- a/packages/midnight-setup/ui/package.json
+++ /dev/null
@@ -1,72 +0,0 @@
-{
- "name": "midnight-setup-ui",
- "private": true,
- "version": "0.0.0",
- "type": "module",
- "scripts": {
- "dev": "vite",
- "start": "http-server --port 0 ./dist",
- "build": "tsc && vite build --mode testnet && cp public/mesh-logo.svg dist/mesh-logo.svg",
- "lint": "eslint .",
- "preview": "vite preview"
- },
- "dependencies": {
- "@meshsdk/midnight-setup": "workspace:*",
- "@midnight-setup/midnight-setup-contract": "workspace:*",
- "@radix-ui/react-dialog": "^1.1.14",
- "@radix-ui/react-label": "^2.1.7",
- "@radix-ui/react-progress": "^1.1.7",
- "@radix-ui/react-slot": "^1.2.3",
- "@tailwindcss/vite": "^4.1.11",
- "badge": "^1.0.3",
- "button": "^1.1.1",
- "card": "^2.5.4",
- "class-variance-authority": "^0.7.1",
- "clsx": "^2.1.1",
- "dialog": "^0.3.1",
- "http-server": "^14.1.1",
- "init": "^0.1.2",
- "input": "^1.0.1",
- "label": "^0.2.2",
- "lucide-react": "^0.523.0",
- "progress": "^2.0.3",
- "react": "^19.1.0",
- "react-dom": "^19.1.0",
- "react-hot-toast": "^2.5.2",
- "shadcn": "^2.7.0",
- "tailwind-merge": "^3.3.1",
- "tailwindcss": "^4.1.11",
- "textarea": "^0.3.0",
- "uuid": "^11.1.0"
- },
- "devDependencies": {
- "@eslint/js": "^9.29.0",
- "@originjs/vite-plugin-commonjs": "^1.0.3",
- "@types/node": "^24.0.4",
- "@types/progress": "^2",
- "@types/react": "^19.1.8",
- "@types/react-dom": "^19.1.6",
- "@vitejs/plugin-react": "^4.5.2",
- "assert": "^2.0.0",
- "browserify-fs": "^1.0.0",
- "buffer": "^6.0.3",
- "crypto-browserify": "^3.12.0",
- "eslint": "^9.29.0",
- "eslint-plugin-react-hooks": "^5.2.0",
- "eslint-plugin-react-refresh": "^0.4.20",
- "globals": "^16.2.0",
- "https-browserify": "^1.0.0",
- "os-browserify": "^0.3.0",
- "process": "^0.11.10",
- "stream-browserify": "^3.0.0",
- "stream-http": "^3.2.0",
- "tw-animate-css": "^1.3.4",
- "typescript": "~5.8.3",
- "typescript-eslint": "^8.34.1",
- "url": "^0.11.0",
- "util": "^0.12.5",
- "vite": "^7.0.0",
- "vite-plugin-top-level-await": "^1.5.0",
- "vite-plugin-wasm": "^3.4.1"
- }
-}
diff --git a/packages/midnight-setup/ui/public/mesh-logo.svg b/packages/midnight-setup/ui/public/mesh-logo.svg
deleted file mode 100644
index 5c4ba0ae5..000000000
--- a/packages/midnight-setup/ui/public/mesh-logo.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/packages/midnight-setup/ui/src/App.tsx b/packages/midnight-setup/ui/src/App.tsx
deleted file mode 100644
index 0be8f4993..000000000
--- a/packages/midnight-setup/ui/src/App.tsx
+++ /dev/null
@@ -1,410 +0,0 @@
-import { useMidnightWallet } from "./hookes/useMidnightWallet";
-import { useDeployedContract } from "./providers/DeployedContractProvider";
-import { Button } from "./components/ui/button";
-import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "./components/ui/card";
-import { Input } from "./components/ui/input";
-import { Label } from "./components/ui/label";
-import { Badge } from "./components/ui/badge";
-import { Wallet, Loader2, CheckCircle, AlertCircle, Database, RefreshCw } from "lucide-react";
-import { useState } from "react";
-import type { ContractStateData, LedgerStateData } from "@meshsdk/midnight-setup";
-
-// Helper to safely stringify unknown data
-const safeStringify = (data: unknown): string => {
- try {
- return JSON.stringify(data, null, 2);
- } catch {
- return "Unable to display data";
- }
-};
-
-function App() {
- const walletContext = useMidnightWallet();
- const contractContext = useDeployedContract();
- const [contractAddress, setContractAddress] = useState("");
- const [contractState, setContractState] = useState(null);
- const [ledgerState, setLedgerState] = useState(null);
- const [isLoadingState, setIsLoadingState] = useState(false);
-
- const handleJoinContract = async () => {
- if (contractAddress.trim()) {
- await contractContext.onJoinContract(contractAddress.trim());
- }
- };
-
- const handleDeployContract = async () => {
- await contractContext.onDeployContract();
- };
-
- const handleGetContractState = async () => {
- if (!contractContext.midnightSetupApi) return;
-
- setIsLoadingState(true);
- try {
- const state = await contractContext.midnightSetupApi.getContractState();
- setContractState(state);
- } catch (error) {
- console.error("Failed to get contract state:", error);
- } finally {
- setIsLoadingState(false);
- }
- };
-
- const handleGetLedgerState = async () => {
- if (!contractContext.midnightSetupApi) return;
-
- setIsLoadingState(true);
- try {
- const state = await contractContext.midnightSetupApi.getLedgerState();
- setLedgerState(state);
- } catch (error) {
- console.error("Failed to get ledger state:", error);
- } finally {
- setIsLoadingState(false);
- }
- };
-
- return (
-
-
-
-
- Midnight Setup
-
-
- Connect your wallet, deploy or join contracts, view contract and ledger states, check your API, access your contract address and functions — all in one place. Modify as you like and just build!
-
-
-
- {/* Wallet Connection Section */}
-
-
-
-
- Wallet Connection
-
-
- Connect to your Midnight wallet to get started
-
-
-
- {walletContext?.walletState.hasConnected ? (
-
-
-
-
- Connected: {walletContext.walletState.address?.slice(0, 6)}...
- {walletContext.walletState.address?.slice(-4)}
-
-
-
-
- Disconnect
-
-
- ) : (
-
-
-
- Wallet not connected
-
-
-
- {walletContext?.walletState.isConnecting ? (
- <>
-
- Connecting...
- >
- ) : (
- "Connect Wallet"
- )}
-
-
- )}
-
- {walletContext?.walletState.error && (
-
-
{walletContext.walletState.error}
-
- Clear Error
-
-
- )}
-
-
-
- {/* Contract Operations Section */}
- {walletContext?.walletState.hasConnected && (
-
-
- Contract Operations
-
- Deploy a new contract or join an existing one
-
-
-
- {/* Deploy Contract */}
-
-
Deploy New Contract
-
-
- {contractContext.isDeploying ? (
- <>
-
- Deploying...
- >
- ) : (
- "Deploy Contract"
- )}
-
- {contractContext.hasDeployed && (
-
-
- Contract deployed at: {contractContext.deployedContractAddress}
-
- )}
-
-
-
- {/* Join Contract */}
-
-
Join Existing Contract
-
-
- Contract Address
- setContractAddress(e.target.value)}
- disabled={contractContext.isJoining}
- />
-
-
- {contractContext.isJoining ? (
- <>
-
- Joining...
- >
- ) : (
- "Join Contract"
- )}
-
-
- {contractContext.hasJoined && (
-
-
- Successfully joined contract at: {contractContext.deployedContractAddress}
-
- )}
-
-
- {/* Error Display */}
- {contractContext.error && (
-
-
{contractContext.error}
-
- Clear Error
-
-
- )}
-
- {/* Contract Status */}
- {(contractContext.hasDeployed || contractContext.hasJoined) && (
-
-
Contract Status
-
-
Status: {contractContext.hasDeployed ? "Deployed" : "Joined"}
-
Address: {contractContext.deployedContractAddress}
-
API Available: {contractContext.midnightSetupApi ? "Yes" : "No"}
-
-
- )}
-
-
- )}
-
- {/* Contract State Reading Section */}
- {(contractContext.hasDeployed || contractContext.hasJoined) && (
-
-
-
-
- Contract State Reader
-
-
- Read and display the current state of the deployed contract
-
-
-
-
-
- {isLoadingState ? (
- <>
-
- Loading...
- >
- ) : (
- <>
-
- Get Contract State
- >
- )}
-
-
- {isLoadingState ? (
- <>
-
- Loading...
- >
- ) : (
- <>
-
- Get Ledger State
- >
- )}
-
-
-
- {/* Contract State Display */}
- {contractState && (
-
-
Contract State
-
-
Address: {contractState.address}
- {contractState.blockHeight && (
-
Block Height: {contractState.blockHeight}
- )}
- {contractState.blockHash && (
-
Block Hash: {contractState.blockHash}
- )}
- {contractState.error && (
-
Error: {contractState.error}
- )}
- {contractState.message && (
-
Message: {contractState.message}
- )}
- {contractState.data !== null && contractState.data !== undefined ? (
-
-
Raw Data:
-
- {safeStringify(contractState.data)}
-
-
- ) : null}
-
-
- )}
-
- {/* Ledger State Display */}
- {ledgerState && (
-
-
Ledger State
-
-
Address: {ledgerState.address}
- {ledgerState.blockHeight && (
-
Block Height: {ledgerState.blockHeight}
- )}
- {ledgerState.blockHash && (
-
Block Hash: {ledgerState.blockHash}
- )}
- {ledgerState.error && (
-
Error: {ledgerState.error}
- )}
- {ledgerState.parseError && (
-
Parse Error: {ledgerState.parseError}
- )}
- {ledgerState.ledgerState && (
-
- {ledgerState.ledgerState.message && (
-
Message: {ledgerState.ledgerState.message}
- )}
-
-
Parsed Data:
-
- {JSON.stringify(ledgerState.ledgerState, null, 2)}
-
-
-
- )}
- {ledgerState.rawData !== null && ledgerState.rawData !== undefined ? (
-
-
Raw Data (could not parse):
-
- {safeStringify(ledgerState.rawData)}
-
-
- ) : null}
-
-
- )}
-
-
- )}
-
- {/* Footer Banner - Powered by MeshJS Team */}
-
-
-
-
- Built with ❤️ on Midnight Network
-
-
-
-
-
- );
-}
-
-export default App;
\ No newline at end of file
diff --git a/packages/midnight-setup/ui/src/components/ui/badge.tsx b/packages/midnight-setup/ui/src/components/ui/badge.tsx
deleted file mode 100644
index 02054139a..000000000
--- a/packages/midnight-setup/ui/src/components/ui/badge.tsx
+++ /dev/null
@@ -1,46 +0,0 @@
-import * as React from "react"
-import { Slot } from "@radix-ui/react-slot"
-import { cva, type VariantProps } from "class-variance-authority"
-
-import { cn } from "@/lib/utils"
-
-const badgeVariants = cva(
- "inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",
- {
- variants: {
- variant: {
- default:
- "border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
- secondary:
- "border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
- destructive:
- "border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
- outline:
- "text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
- },
- },
- defaultVariants: {
- variant: "default",
- },
- }
-)
-
-function Badge({
- className,
- variant,
- asChild = false,
- ...props
-}: React.ComponentProps<"span"> &
- VariantProps & { asChild?: boolean }) {
- const Comp = asChild ? Slot : "span"
-
- return (
-
- )
-}
-
-export { Badge, badgeVariants }
diff --git a/packages/midnight-setup/ui/src/components/ui/button.tsx b/packages/midnight-setup/ui/src/components/ui/button.tsx
deleted file mode 100644
index a2df8dce6..000000000
--- a/packages/midnight-setup/ui/src/components/ui/button.tsx
+++ /dev/null
@@ -1,59 +0,0 @@
-import * as React from "react"
-import { Slot } from "@radix-ui/react-slot"
-import { cva, type VariantProps } from "class-variance-authority"
-
-import { cn } from "@/lib/utils"
-
-const buttonVariants = cva(
- "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
- {
- variants: {
- variant: {
- default:
- "bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",
- destructive:
- "bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
- outline:
- "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
- secondary:
- "bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",
- ghost:
- "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
- link: "text-primary underline-offset-4 hover:underline",
- },
- size: {
- default: "h-9 px-4 py-2 has-[>svg]:px-3",
- sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
- lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
- icon: "size-9",
- },
- },
- defaultVariants: {
- variant: "default",
- size: "default",
- },
- }
-)
-
-function Button({
- className,
- variant,
- size,
- asChild = false,
- ...props
-}: React.ComponentProps<"button"> &
- VariantProps & {
- asChild?: boolean
- }) {
- const Comp = asChild ? Slot : "button"
-
- return (
-
- )
-}
-
-export { Button, buttonVariants }
diff --git a/packages/midnight-setup/ui/src/components/ui/card.tsx b/packages/midnight-setup/ui/src/components/ui/card.tsx
deleted file mode 100644
index d05bbc6c7..000000000
--- a/packages/midnight-setup/ui/src/components/ui/card.tsx
+++ /dev/null
@@ -1,92 +0,0 @@
-import * as React from "react"
-
-import { cn } from "@/lib/utils"
-
-function Card({ className, ...props }: React.ComponentProps<"div">) {
- return (
-
- )
-}
-
-function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
- return (
-
- )
-}
-
-function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
- return (
-
- )
-}
-
-function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
- return (
-
- )
-}
-
-function CardAction({ className, ...props }: React.ComponentProps<"div">) {
- return (
-
- )
-}
-
-function CardContent({ className, ...props }: React.ComponentProps<"div">) {
- return (
-
- )
-}
-
-function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
- return (
-
- )
-}
-
-export {
- Card,
- CardHeader,
- CardFooter,
- CardTitle,
- CardAction,
- CardDescription,
- CardContent,
-}
diff --git a/packages/midnight-setup/ui/src/components/ui/dialog.tsx b/packages/midnight-setup/ui/src/components/ui/dialog.tsx
deleted file mode 100644
index 6cb123b38..000000000
--- a/packages/midnight-setup/ui/src/components/ui/dialog.tsx
+++ /dev/null
@@ -1,141 +0,0 @@
-import * as React from "react"
-import * as DialogPrimitive from "@radix-ui/react-dialog"
-import { XIcon } from "lucide-react"
-
-import { cn } from "@/lib/utils"
-
-function Dialog({
- ...props
-}: React.ComponentProps) {
- return
-}
-
-function DialogTrigger({
- ...props
-}: React.ComponentProps) {
- return
-}
-
-function DialogPortal({
- ...props
-}: React.ComponentProps) {
- return
-}
-
-function DialogClose({
- ...props
-}: React.ComponentProps) {
- return
-}
-
-function DialogOverlay({
- className,
- ...props
-}: React.ComponentProps) {
- return (
-
- )
-}
-
-function DialogContent({
- className,
- children,
- showCloseButton = true,
- ...props
-}: React.ComponentProps & {
- showCloseButton?: boolean
-}) {
- return (
-
-
-
- {children}
- {showCloseButton && (
-
-
- Close
-
- )}
-
-
- )
-}
-
-function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
- return (
-
- )
-}
-
-function DialogFooter({ className, ...props }: React.ComponentProps<"div">) {
- return (
-
- )
-}
-
-function DialogTitle({
- className,
- ...props
-}: React.ComponentProps) {
- return (
-
- )
-}
-
-function DialogDescription({
- className,
- ...props
-}: React.ComponentProps) {
- return (
-
- )
-}
-
-export {
- Dialog,
- DialogClose,
- DialogContent,
- DialogDescription,
- DialogFooter,
- DialogHeader,
- DialogOverlay,
- DialogPortal,
- DialogTitle,
- DialogTrigger,
-}
diff --git a/packages/midnight-setup/ui/src/components/ui/input.tsx b/packages/midnight-setup/ui/src/components/ui/input.tsx
deleted file mode 100644
index 03295ca6a..000000000
--- a/packages/midnight-setup/ui/src/components/ui/input.tsx
+++ /dev/null
@@ -1,21 +0,0 @@
-import * as React from "react"
-
-import { cn } from "@/lib/utils"
-
-function Input({ className, type, ...props }: React.ComponentProps<"input">) {
- return (
-
- )
-}
-
-export { Input }
diff --git a/packages/midnight-setup/ui/src/components/ui/label.tsx b/packages/midnight-setup/ui/src/components/ui/label.tsx
deleted file mode 100644
index ef7133a75..000000000
--- a/packages/midnight-setup/ui/src/components/ui/label.tsx
+++ /dev/null
@@ -1,22 +0,0 @@
-import * as React from "react"
-import * as LabelPrimitive from "@radix-ui/react-label"
-
-import { cn } from "@/lib/utils"
-
-function Label({
- className,
- ...props
-}: React.ComponentProps) {
- return (
-
- )
-}
-
-export { Label }
diff --git a/packages/midnight-setup/ui/src/components/ui/progress.tsx b/packages/midnight-setup/ui/src/components/ui/progress.tsx
deleted file mode 100644
index e7a416c37..000000000
--- a/packages/midnight-setup/ui/src/components/ui/progress.tsx
+++ /dev/null
@@ -1,31 +0,0 @@
-"use client"
-
-import * as React from "react"
-import * as ProgressPrimitive from "@radix-ui/react-progress"
-
-import { cn } from "@/lib/utils"
-
-function Progress({
- className,
- value,
- ...props
-}: React.ComponentProps) {
- return (
-
-
-
- )
-}
-
-export { Progress }
diff --git a/packages/midnight-setup/ui/src/components/ui/textarea.tsx b/packages/midnight-setup/ui/src/components/ui/textarea.tsx
deleted file mode 100644
index 7f21b5e78..000000000
--- a/packages/midnight-setup/ui/src/components/ui/textarea.tsx
+++ /dev/null
@@ -1,18 +0,0 @@
-import * as React from "react"
-
-import { cn } from "@/lib/utils"
-
-function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
- return (
-
- )
-}
-
-export { Textarea }
diff --git a/packages/midnight-setup/ui/src/hookes/useMidnightWallet.tsx b/packages/midnight-setup/ui/src/hookes/useMidnightWallet.tsx
deleted file mode 100644
index 2ef1d3716..000000000
--- a/packages/midnight-setup/ui/src/hookes/useMidnightWallet.tsx
+++ /dev/null
@@ -1,12 +0,0 @@
-import { MidnightWalletContext } from '@/providers/MidnightWalletProvider'
-import { useContext } from 'react'
-
-export const useMidnightWallet = () => {
- const context = useContext(MidnightWalletContext)
- if(!context){
- return;
- }
- return context;
-}
-
-export default useMidnightWallet
\ No newline at end of file
diff --git a/packages/midnight-setup/ui/src/index.css b/packages/midnight-setup/ui/src/index.css
deleted file mode 100644
index 5a7873abc..000000000
--- a/packages/midnight-setup/ui/src/index.css
+++ /dev/null
@@ -1,2 +0,0 @@
-@import "tailwindcss";
-@import "tw-animate-css";
diff --git a/packages/midnight-setup/ui/src/lib/actions.ts b/packages/midnight-setup/ui/src/lib/actions.ts
deleted file mode 100644
index 48e58deaa..000000000
--- a/packages/midnight-setup/ui/src/lib/actions.ts
+++ /dev/null
@@ -1,226 +0,0 @@
-import { type ContractAddress } from "@midnight-ntwrk/compact-runtime";
-import {
- concatMap,
- filter,
- firstValueFrom,
- interval,
- map,
- of,
- take,
- tap,
- throwError,
- timeout,
- catchError,
-} from "rxjs";
-import { pipe as fnPipe } from "fp-ts/function";
-import {
- type DAppConnectorAPI,
- type DAppConnectorWalletAPI,
- type ServiceUriConfig,
-} from "@midnight-ntwrk/dapp-connector-api";
-import { levelPrivateStateProvider } from "@midnight-ntwrk/midnight-js-level-private-state-provider";
-import { FetchZkConfigProvider } from "@midnight-ntwrk/midnight-js-fetch-zk-config-provider";
-import { httpClientProofProvider } from "@midnight-ntwrk/midnight-js-http-client-proof-provider";
-import { indexerPublicDataProvider } from "@midnight-ntwrk/midnight-js-indexer-public-data-provider";
-import {
- type BalancedTransaction,
- type UnbalancedTransaction,
- createBalancedTx,
-} from "@midnight-ntwrk/midnight-js-types";
-import {
- type CoinInfo,
- Transaction,
- type TransactionId,
-} from "@midnight-ntwrk/ledger";
-import { Transaction as ZswapTransaction } from "@midnight-ntwrk/zswap";
-import semver from "semver";
-import {
- getLedgerNetworkId,
- getZswapNetworkId,
-} from "@midnight-ntwrk/midnight-js-network-id";
-import {
- MidnightSetupAPI,
- type MidnightSetupContractProviders,
- type DeployedMidnightSetupAPI,
- type TokenCircuitKeys,
-} from "@meshsdk/midnight-setup";
-import type { WalletAndProvider } from "./common-types";
-import type { Logger } from "pino";
-
-const connectWallet = async (): Promise<{
- wallet: DAppConnectorWalletAPI;
- uris: ServiceUriConfig;
-}> => {
- const COMPATIBLE_CONNECTOR_API_VERSION = "1.x";
- return firstValueFrom(
- fnPipe(
- interval(100),
- map(() => window.midnight?.mnLace),
- tap((connectorAPI) => {
- console.info(connectorAPI, "Check for wallet connector API");
- }),
- filter(
- (connectorAPI): connectorAPI is DAppConnectorAPI => !!connectorAPI
- ),
- concatMap((connectorAPI) =>
- semver.satisfies(
- connectorAPI.apiVersion,
- COMPATIBLE_CONNECTOR_API_VERSION
- )
- ? of(connectorAPI)
- : throwError(() => {
- console.error(
- {
- expected: COMPATIBLE_CONNECTOR_API_VERSION,
- actual: connectorAPI.apiVersion,
- },
- "Incompatible version of wallet connector API"
- );
-
- return new Error(
- `Incompatible version of Midnight Lace wallet found. Require '${COMPATIBLE_CONNECTOR_API_VERSION}', got '${connectorAPI.apiVersion}'.`
- );
- })
- ),
- tap((connectorAPI) => {
- console.info(
- connectorAPI,
- "Compatible wallet connector API found. Connecting."
- );
- }),
- take(1),
- timeout({
- first: 1_000,
- with: () =>
- throwError(() => {
- console.error("Could not find wallet connector API");
-
- return new Error(
- "Could not find Midnight Lace wallet. Extension installed?"
- );
- }),
- }),
- concatMap(async (connectorAPI) => {
- const isEnabled = await connectorAPI.isEnabled();
-
- console.info(isEnabled, "Wallet connector API enabled status");
-
- return connectorAPI;
- }),
- timeout({
- first: 5_000,
- with: () =>
- throwError(() => {
- console.error("Wallet connector API has failed to respond");
-
- return new Error(
- "Midnight Lace wallet has failed to respond. Extension enabled?"
- );
- }),
- }),
- concatMap(async (connectorAPI) => ({
- walletConnectorAPI: await connectorAPI.enable(),
- connectorAPI,
- })),
- catchError((error, apis) =>
- error
- ? throwError(() => {
- console.error("Unable to enable connector API");
- return new Error("Application is not authorized");
- })
- : apis
- ),
- concatMap(async ({ walletConnectorAPI, connectorAPI }) => {
- const uris = await connectorAPI.serviceUriConfig();
-
- console.info(
- "Connected to wallet connector API and retrieved service configuration"
- );
-
- return { wallet: walletConnectorAPI, uris };
- })
- )
- );
-};
-
-export const initialWalletAndProviders =
- async (): Promise => {
- const { wallet, uris } = await connectWallet();
- const walletState = await wallet.state();
-
- const providers = {
- privateStateProvider: levelPrivateStateProvider({
- privateStateStoreName: "midnight-setup-private-state",
- }),
- zkConfigProvider: new FetchZkConfigProvider(
- window.location.origin,
- fetch.bind(window)
- ),
- proofProvider: httpClientProofProvider(uris.proverServerUri),
- publicDataProvider: indexerPublicDataProvider(
- uris.indexerUri,
- uris.indexerWsUri
- ),
- walletProvider: {
- coinPublicKey: walletState.coinPublicKey,
- encryptionPublicKey: walletState.encryptionPublicKey,
- balanceTx(
- tx: UnbalancedTransaction,
- newCoins: CoinInfo[]
- ): Promise {
- return wallet
- .balanceAndProveTransaction(
- ZswapTransaction.deserialize(
- tx.serialize(getLedgerNetworkId()),
- getZswapNetworkId()
- ),
- newCoins
- )
- .then((zswapTx) =>
- Transaction.deserialize(
- zswapTx.serialize(getZswapNetworkId()),
- getLedgerNetworkId()
- )
- )
- .then(createBalancedTx)
- .finally(() => {
- console.log("balanceTxDone");
- });
- },
- },
- midnightProvider: {
- submitTx(tx: BalancedTransaction): Promise {
- return wallet.submitTransaction(tx);
- },
- },
- };
-
- return { wallet, uris, providers };
- };
-
-export const resolve = async (
- providers: MidnightSetupContractProviders,
- logger: Logger,
- contractAddress?: ContractAddress
-): Promise => {
- let api;
- if (contractAddress) {
- api = await MidnightSetupAPI.joinMidnightSetupContract(
- providers,
- contractAddress
- );
- } else {
- api = await MidnightSetupAPI.deployMidnightSetupContract(providers, logger);
- }
-
- return api;
-};
-
-export const calculateExpiryDate = (duration: number, creationDate: number) => {
- const millisecondsPerHour = 1000 * 60 * 60 * 24;
- const durationInMilliseconds = millisecondsPerHour * duration;
- const expiryDate = creationDate + durationInMilliseconds;
-
- const dateObject = new Date(expiryDate);
- return dateObject.toLocaleDateString();
-};
diff --git a/packages/midnight-setup/ui/src/lib/common-types.ts b/packages/midnight-setup/ui/src/lib/common-types.ts
deleted file mode 100644
index 48f438c0a..000000000
--- a/packages/midnight-setup/ui/src/lib/common-types.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import type { MidnightSetupContractProviders, DeployedMidnightSetupAPI } from "@meshsdk/midnight-setup";
-import type { DAppConnectorWalletAPI, ServiceUriConfig } from "@midnight-ntwrk/dapp-connector-api";
-
-
-export interface WalletAndProvider{
- readonly wallet: DAppConnectorWalletAPI,
- readonly uris: ServiceUriConfig,
- readonly providers: MidnightSetupContractProviders
-}
-
-export interface WalletAPI {
- wallet: DAppConnectorWalletAPI;
- coinPublicKey: string;
- encryptionPublicKey: string;
- uris: ServiceUriConfig;
-}
-
-
-export interface MidnightSetupDeployment{
- status: "inprogress" | "deployed" | "failed",
- api: DeployedMidnightSetupAPI;
-}
\ No newline at end of file
diff --git a/packages/midnight-setup/ui/src/lib/utils.ts b/packages/midnight-setup/ui/src/lib/utils.ts
deleted file mode 100644
index bd0c391dd..000000000
--- a/packages/midnight-setup/ui/src/lib/utils.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { clsx, type ClassValue } from "clsx"
-import { twMerge } from "tailwind-merge"
-
-export function cn(...inputs: ClassValue[]) {
- return twMerge(clsx(inputs))
-}
diff --git a/packages/midnight-setup/ui/src/main.tsx b/packages/midnight-setup/ui/src/main.tsx
deleted file mode 100644
index 1ffd831da..000000000
--- a/packages/midnight-setup/ui/src/main.tsx
+++ /dev/null
@@ -1,31 +0,0 @@
-import { StrictMode } from "react";
-import './polyfills'
-import { createRoot } from "react-dom/client";
-import "./index.css";
-import App from "./App.tsx";
-import MidnightWalletProvider from "./providers/MidnightWalletProvider.tsx";
-import DeployedContractProvider from "./providers/DeployedContractProvider.tsx";
-import pino from "pino";
-import { setNetworkId, type NetworkId } from "@midnight-ntwrk/midnight-js-network-id";
-
-const networkId = import.meta.env.VITE_NETWORK_ID as NetworkId;
-// Ensure that the network IDs are set within the Midnight libraries.
-setNetworkId(networkId);
-
-// Create a default `pino` logger and configure it with the configured logging level.
-export const logger = pino({
- level: import.meta.env.VITE_LOGGING_LEVEL as string,
-});
-
-logger.trace('networkId = ', networkId);
-
-createRoot(document.getElementById("root")!).render(
-
-
-
-
-
-
-
-);
-
diff --git a/packages/midnight-setup/ui/src/polyfills.ts b/packages/midnight-setup/ui/src/polyfills.ts
deleted file mode 100644
index ad66ba461..000000000
--- a/packages/midnight-setup/ui/src/polyfills.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-// src/polyfills.ts - Create this file
-import { Buffer } from 'buffer'
-
-// Make Buffer available globally
-window.Buffer = Buffer
-window.global = window.global || window
-window.process = window.process || { env: {} }
-
-// Export for direct imports
-export { Buffer }
\ No newline at end of file
diff --git a/packages/midnight-setup/ui/src/providers/DeployedContractProvider.tsx b/packages/midnight-setup/ui/src/providers/DeployedContractProvider.tsx
deleted file mode 100644
index 35c736961..000000000
--- a/packages/midnight-setup/ui/src/providers/DeployedContractProvider.tsx
+++ /dev/null
@@ -1,160 +0,0 @@
-import useMidnightWallet from "@/hookes/useMidnightWallet";
-import { MidnightSetupAPI, type DeployedMidnightSetupAPI } from "@meshsdk/midnight-setup";
-import type { Logger } from "pino";
-import {
- createContext,
- useCallback,
- useContext,
- useState,
- type PropsWithChildren,
-} from "react";
-
-export interface DeploymentProvider {
- readonly isJoining: boolean;
- readonly isDeploying: boolean;
- readonly error: string | null;
- readonly hasJoined: boolean;
- readonly hasDeployed: boolean;
- readonly midnightSetupApi: DeployedMidnightSetupAPI | undefined;
- readonly deployedContractAddress: string | undefined;
- onJoinContract: (address: string) => Promise;
- onDeployContract: () => Promise;
- clearError: () => void;
-}
-
-export const DeployedContractContext = createContext(null);
-
-interface DeployedContractProviderProps extends PropsWithChildren {
- logger?: Logger;
-}
-
-const DeployedContractProvider = ({
- children,
- logger
-}: DeployedContractProviderProps) => {
-
- const [midnightSetupApi, setMidnightSetupApi] = useState(undefined);
- const [isJoining, setIsJoining] = useState(false);
- const [isDeploying, setIsDeploying] = useState(false);
- const [error, setError] = useState(null);
- const [hasJoined, setHasJoined] = useState(false);
- const [hasDeployed, setHasDeployed] = useState(false);
- const [deployedContractAddress, setDeployedContractAddress] = useState(undefined);
-
- // Use the custom hook instead of useContext directly
- const walletContext = useMidnightWallet();
-
- const onJoinContract = useCallback(async (address: string) => {
- // Prevent multiple simultaneous joins
- if (isJoining || hasJoined || isDeploying || hasDeployed) return;
-
- // Validate requirements
- if (!walletContext?.walletState.hasConnected || !walletContext?.walletState.providers) {
- setError("Wallet must be connected before joining contract");
- return;
- }
-
- if (!address) {
- setError("Contract address is required");
- return;
- }
-
- setIsJoining(true);
- setError(null);
-
- try {
- const deployedAPI = await MidnightSetupAPI.joinMidnightSetupContract(
- walletContext.walletState.providers,
- address,
- logger
- );
-
- setMidnightSetupApi(deployedAPI);
- setHasJoined(true);
- setDeployedContractAddress(deployedAPI.deployedContractAddress);
- logger?.info("Successfully joined contract", { contractAddress: address });
-
- } catch (error) {
- const errMsg = error instanceof Error
- ? error.message
- : `Failed to join contract at ${address}`;
- setError(errMsg);
- logger?.error("Failed to join contract", { error: errMsg, contractAddress: address });
- } finally {
- setIsJoining(false);
- }
- }, [isJoining, hasJoined, isDeploying, hasDeployed, walletContext?.walletState.hasConnected, walletContext?.walletState.providers, logger]);
-
- const onDeployContract = useCallback(async () => {
- // Prevent multiple simultaneous operations
- if (isDeploying || hasDeployed || isJoining || hasJoined) return;
-
- // Validate requirements
- if (!walletContext?.walletState.hasConnected || !walletContext?.walletState.providers) {
- setError("Wallet must be connected before deploying contract");
- return;
- }
-
- setIsDeploying(true);
- setError(null);
-
- try {
- const deployedAPI = await MidnightSetupAPI.deployMidnightSetupContract(
- walletContext.walletState.providers,
- logger
- );
-
- setMidnightSetupApi(deployedAPI);
- setHasDeployed(true);
- setDeployedContractAddress(deployedAPI.deployedContractAddress);
- logger?.info("Successfully deployed new contract", {
- contractAddress: deployedAPI.deployedContractAddress
- });
-
- } catch (error) {
- const errMsg = error instanceof Error
- ? error.message
- : "Failed to deploy new contract";
- setError(errMsg);
- logger?.error("Failed to deploy contract", { error: errMsg });
- } finally {
- setIsDeploying(false);
- }
- }, [isDeploying, hasDeployed, isJoining, hasJoined, walletContext?.walletState.hasConnected, walletContext?.walletState.providers, logger]);
-
- const clearError = useCallback(() => {
- setError(null);
- }, []);
-
- const contextValue: DeploymentProvider = {
- isJoining,
- isDeploying,
- hasJoined,
- hasDeployed,
- error,
- midnightSetupApi,
- deployedContractAddress,
- onJoinContract,
- onDeployContract,
- clearError,
- };
-
- return (
-
- {children}
-
- );
-};
-
-// Custom hook for consuming the context
-export const useDeployedContract = (): DeploymentProvider => {
- const context = useContext(DeployedContractContext);
-
- if (!context) {
- throw new Error("useDeployedContract must be used within a DeployedContractProvider");
- }
-
- return context;
-};
-
-export default DeployedContractProvider;
\ No newline at end of file
diff --git a/packages/midnight-setup/ui/src/providers/MidnightWalletProvider.tsx b/packages/midnight-setup/ui/src/providers/MidnightWalletProvider.tsx
deleted file mode 100644
index e90d9a73c..000000000
--- a/packages/midnight-setup/ui/src/providers/MidnightWalletProvider.tsx
+++ /dev/null
@@ -1,173 +0,0 @@
-import { initialWalletAndProviders } from "@/lib/actions";
-import type { WalletAPI } from "@/lib/common-types";
-import type { MidnightSetupContractProviders } from "@meshsdk/midnight-setup";
-import type { Logger } from "pino";
-import {
- createContext,
- useReducer,
- useCallback,
- type PropsWithChildren,
-} from "react";
-
-export interface MidnightWalletState {
- readonly address: string | undefined;
- readonly isConnecting: boolean;
- readonly coinPublicKey: string | undefined;
- readonly providers: MidnightSetupContractProviders | undefined;
- readonly walletAPI: WalletAPI | undefined;
- readonly hasConnected: boolean;
- readonly error: string | null;
-}
-
-export interface MidnightWalletContextType {
- walletState: MidnightWalletState;
- connectToWalletAndInitializeProviders: () => Promise;
- disconnect: () => void;
- clearError: () => void;
-}
-
-// Initial state
-const initialState: MidnightWalletState = {
- address: undefined,
- isConnecting: false,
- coinPublicKey: undefined,
- providers: undefined,
- walletAPI: undefined,
- hasConnected: false,
- error: null,
-};
-
-// Action types
-type WalletAction =
- | { type: "CONNECT_START" }
- | {
- type: "CONNECT_SUCCESS";
- payload: Omit<
- MidnightWalletState,
- "isConnecting" | "hasConnected" | "error"
- >;
- }
- | { type: "CONNECT_ERROR"; payload: string }
- | { type: "DISCONNECT" }
- | { type: "CLEAR_ERROR" };
-
-// Reducer
-function walletReducer(
- state: MidnightWalletState,
- action: WalletAction
-): MidnightWalletState {
- switch (action.type) {
- case "CONNECT_START":
- return {
- ...state,
- isConnecting: true,
- error: null,
- };
- case "CONNECT_SUCCESS":
- return {
- ...state,
- ...action.payload,
- isConnecting: false,
- hasConnected: true,
- error: null,
- };
- case "CONNECT_ERROR":
- return {
- ...state,
- isConnecting: false,
- error: action.payload,
- };
- case "DISCONNECT":
- return {
- ...initialState,
- hasConnected: false,
- };
- case "CLEAR_ERROR":
- return {
- ...state,
- error: null,
- };
- default:
- return state;
- }
-}
-
-// Context
-export const MidnightWalletContext =
- createContext(null);
-
-// Provider Props
-interface MidnightWalletProviderProps extends PropsWithChildren {
- logger?: Logger;
-}
-
-const MidnightWalletProvider = ({
- children,
- logger,
-}: MidnightWalletProviderProps) => {
- const [walletState, dispatch] = useReducer(walletReducer, initialState);
-
- const connectToWalletAndInitializeProviders = useCallback(async () => {
- if (walletState.isConnecting) return; // Prevent multiple simultaneous connections
-
- dispatch({ type: "CONNECT_START" });
-
- try {
- const { wallet, uris, providers } = await initialWalletAndProviders();
-
- if (!wallet) {
- throw new Error("Failed to initialize wallet");
- }
-
- const walletStateData = await wallet.state();
-
- dispatch({
- type: "CONNECT_SUCCESS",
- payload: {
- address: walletStateData.address,
- coinPublicKey: walletStateData.coinPublicKey,
- providers,
- walletAPI: {
- wallet,
- uris,
- coinPublicKey: walletStateData.coinPublicKey,
- encryptionPublicKey: walletStateData.encryptionPublicKey,
- },
- },
- });
-
- logger?.info("Wallet connected successfully", {
- address: walletStateData.address,
- });
- } catch (error) {
- const errorMessage =
- error instanceof Error ? error.message : "Failed to initialize wallet";
- dispatch({ type: "CONNECT_ERROR", payload: errorMessage });
- logger?.error("Wallet connection failed", { error: errorMessage });
- }
- }, [walletState.isConnecting, logger]);
-
- const disconnect = useCallback(() => {
- dispatch({ type: "DISCONNECT" });
- logger?.info("Wallet disconnected");
- }, [logger]);
-
- const clearError = useCallback(() => {
- dispatch({ type: "CLEAR_ERROR" });
- }, []);
-
- const contextValue: MidnightWalletContextType = {
- walletState,
- connectToWalletAndInitializeProviders,
- disconnect,
- clearError,
- };
-
- return (
-
- {children}
-
- );
-};
-
-export default MidnightWalletProvider;
diff --git a/packages/midnight-setup/ui/src/vite-env.d.ts b/packages/midnight-setup/ui/src/vite-env.d.ts
deleted file mode 100644
index 11f02fe2a..000000000
--- a/packages/midnight-setup/ui/src/vite-env.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-///
diff --git a/packages/midnight-setup/ui/tailwind.config.js b/packages/midnight-setup/ui/tailwind.config.js
deleted file mode 100644
index 89a305e02..000000000
--- a/packages/midnight-setup/ui/tailwind.config.js
+++ /dev/null
@@ -1,11 +0,0 @@
-/** @type {import('tailwindcss').Config} */
-export default {
- content: [
- "./index.html",
- "./src/**/*.{js,ts,jsx,tsx}",
- ],
- theme: {
- extend: {},
- },
- plugins: [],
-}
\ No newline at end of file
diff --git a/packages/midnight-setup/ui/tsconfig.app.json b/packages/midnight-setup/ui/tsconfig.app.json
deleted file mode 100644
index f39faca89..000000000
--- a/packages/midnight-setup/ui/tsconfig.app.json
+++ /dev/null
@@ -1,31 +0,0 @@
-{
- "compilerOptions": {
- "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
- "target": "ES2022",
- "useDefineForClassFields": true,
- "lib": ["ES2022", "DOM", "DOM.Iterable"],
- "module": "ESNext",
- "skipLibCheck": true,
- "baseUrl": ".",
- "paths": {
- "@/*": ["./src/*"]
- },
-
- /* Bundler mode */
- "moduleResolution": "bundler",
- "allowImportingTsExtensions": true,
- "verbatimModuleSyntax": true,
- "moduleDetection": "force",
- "noEmit": true,
- "jsx": "react-jsx",
-
- /* Linting */
- "strict": true,
- "noUnusedLocals": true,
- "noUnusedParameters": true,
- "erasableSyntaxOnly": true,
- "noFallthroughCasesInSwitch": true,
- "noUncheckedSideEffectImports": true
- },
- "include": ["src"]
-}
diff --git a/packages/midnight-setup/ui/tsconfig.json b/packages/midnight-setup/ui/tsconfig.json
deleted file mode 100644
index fec8c8e5c..000000000
--- a/packages/midnight-setup/ui/tsconfig.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "files": [],
- "references": [
- { "path": "./tsconfig.app.json" },
- { "path": "./tsconfig.node.json" }
- ],
- "compilerOptions": {
- "baseUrl": ".",
- "paths": {
- "@/*": ["./src/*"]
- }
- }
-}
diff --git a/packages/midnight-setup/ui/tsconfig.node.json b/packages/midnight-setup/ui/tsconfig.node.json
deleted file mode 100644
index f85a39906..000000000
--- a/packages/midnight-setup/ui/tsconfig.node.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
- "compilerOptions": {
- "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
- "target": "ES2023",
- "lib": ["ES2023"],
- "module": "ESNext",
- "skipLibCheck": true,
-
- /* Bundler mode */
- "moduleResolution": "bundler",
- "allowImportingTsExtensions": true,
- "verbatimModuleSyntax": true,
- "moduleDetection": "force",
- "noEmit": true,
-
- /* Linting */
- "strict": true,
- "noUnusedLocals": true,
- "noUnusedParameters": true,
- "erasableSyntaxOnly": true,
- "noFallthroughCasesInSwitch": true,
- "noUncheckedSideEffectImports": true
- },
- "include": ["vite.config.ts"]
-}
diff --git a/packages/midnight-setup/ui/vite.config.ts b/packages/midnight-setup/ui/vite.config.ts
deleted file mode 100644
index 17ee72c60..000000000
--- a/packages/midnight-setup/ui/vite.config.ts
+++ /dev/null
@@ -1,44 +0,0 @@
-import { defineConfig } from "vite";
-import react from "@vitejs/plugin-react";
-import tailwindcss from "@tailwindcss/vite";
-import path from "path";
-import { viteCommonjs } from "@originjs/vite-plugin-commonjs";
-import wasm from "vite-plugin-wasm";
-import topLevelAwait from "vite-plugin-top-level-await";
-
-// https://vite.dev/config/
-export default defineConfig({
- cacheDir: "./.vite",
- build: {
- target: "esnext",
- minify: false,
- },
- plugins: [react(), tailwindcss(), wasm(), topLevelAwait(), viteCommonjs()],
- resolve: {
- alias: {
- "@": path.resolve(__dirname, "./src"),
- buffer: 'buffer',
- process: 'process/browser',
- util: 'util',
- crypto: 'crypto-browserify',
- stream: 'stream-browserify',
- assert: 'assert',
- http: 'stream-http',
- https: 'https-browserify',
- os: 'os-browserify',
- url: 'url',
- fs: 'browserify-fs',
- },
-
- },
- optimizeDeps: {
- esbuildOptions: {
- target: "esnext",
- },
- include: [
- 'buffer',
- 'process',
- ],
- },
- define: {},
-});
diff --git a/scripts/mesh-cli/package.json b/scripts/mesh-cli/package.json
index d39f432cb..1129f6069 100644
--- a/scripts/mesh-cli/package.json
+++ b/scripts/mesh-cli/package.json
@@ -3,7 +3,7 @@
"description": "A quick and easy way to bootstrap your Web3 app using Mesh.",
"homepage": "https://meshjs.dev",
"author": "MeshJS",
- "version": "1.9.0-beta.80",
+ "version": "1.9.0-beta.81",
"license": "Apache-2.0",
"type": "module",
"main": "./dist/index.cjs",