Skip to content

Commit

Permalink
Merge pull request #3105 from cardano-foundation/1.0.0
Browse files Browse the repository at this point in the history
Merge 1.0.0 into main
  • Loading branch information
cfuisat authored Mar 21, 2024
2 parents 56af853 + 6f3e9b2 commit 6faa386
Show file tree
Hide file tree
Showing 48 changed files with 2,080 additions and 548 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
release-type: node
bump-minor-pre-major: true
bump-patch-for-minor-pre-major: true
release-as: 0.9.0
release-as: 1.0.0
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
run: npm ci

- name: 🎳 Run tests
run: npm run test:jest:ci
run: npm run test
97 changes: 53 additions & 44 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0" />
<meta name="theme-color" content="#fff" />
<meta name="description" content="Cardano Blockchain Explorer" />
<link rel="icon" href="/favicon.ico" />
<link rel="apple-touch-icon" href="/logo192.png" />
<link rel="shortcut icon" href="/logo16.png" />
<link rel="shortcut icon" href="/logo32.png" />
<link rel="shortcut icon" href="/logo64.png" />
<link rel="shortcut icon" href="/logo128.png" />
<link rel="shortcut icon" href="/logo196.png" />
<link rel="shortcut icon" href="/logo512.png" />
<!--
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0" />
<meta name="theme-color" content="#fff" />
<meta name="description" content="Cardano Blockchain Explorer" />
<link rel="icon" href="/favicon.ico" />
<link rel="apple-touch-icon" href="/logo192.png" />
<link rel="shortcut icon" href="/logo16.png" />
<link rel="shortcut icon" href="/logo32.png" />
<link rel="shortcut icon" href="/logo64.png" />
<link rel="shortcut icon" href="/logo128.png" />
<link rel="shortcut icon" href="/logo196.png" />
<link rel="shortcut icon" href="/logo512.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="/manifest.json" />
<link rel="manifest" href="/manifest.json" />

<!--
<!--
Notice the use of in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Expand All @@ -29,13 +28,13 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Cardano Blockchain Explorer</title>
</head>
<title>Cardano Blockchain Explorer</title>
</head>

<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
Expand All @@ -45,25 +44,35 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
<script src="/assets/env.global.js" type="text/javascript"></script>
<script>
var isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
document.addEventListener("gesturestart", function (e) {
e.preventDefault();
});
document.addEventListener(
"touchmove",
function (event) {
if (event.scale !== 1 && isIOS) {
event.preventDefault();
}
},
{ passive: false }
);
</script>
<script data-jsd-embedded data-key="%REACT_APP_JSD_WIDGET_KEY%" data-base-url="https://jsd-widget.atlassian.com"
src="https://jsd-widget.atlassian.com/assets/embed.js"></script>
<script type="module" src="/src/index.tsx"></script>
</body>
<script src="/assets/env.global.js" type="text/javascript"></script>

</html>
<script type="module">
import init, { decode } from "/lib/pkg/uplc_js.js";
init().then(() => {
window.decodeUPLC = decode;
});
</script>
<script>
var isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
document.addEventListener("gesturestart", function (e) {
e.preventDefault();
});
document.addEventListener(
"touchmove",
function (event) {
if (event.scale !== 1 && isIOS) {
event.preventDefault();
}
},
{ passive: false }
);
</script>
<script
data-jsd-embedded
data-key="%REACT_APP_JSD_WIDGET_KEY%"
data-base-url="https://jsd-widget.atlassian.com"
src="https://jsd-widget.atlassian.com/assets/embed.js"
></script>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
71 changes: 71 additions & 0 deletions lib/pkg/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Project Name

UPLC-JS

## Overview

This project utilizes a WebAssembly module to decode flat data, providing a crucial tool for the Cardano Explorer. Leveraging Aiken's library https://github.com/aiken-lang/aiken, we've built a WebAssembly version of the decoder, making it accessible for web applications.

## Table of Contents

- [Installation](#installation)
- [Usage](#usage)
- [Update](#update)
- [Special Thanks](#special-thanks)

## Installation

Describe how to install and set up your project. Include any prerequisites, such as Rust and wasm-pack, if necessary.

1. Clone this repository:
```bash
git clone https://github.com/yourusername/yourproject.git
```
2. Install Rust:
```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```
3. Install wasm-pack:
```bash
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
```
4. Build the project:
```bash
wasm-pack build --target web
```

## Usage

### Using the WebAssembly Module

1. Add the following script tag to your HTML file:
```html
<script type="module">
import { decode } from './pkg/uplc-js.js';
async function run() {
const yourFlat = "abc123";
const decoded = decode(yourFlat);
console.log(decoded)
}
run();
</script>
```
2. Call the exported functions from your JavaScript code:
```javascript
decode();
```
## Update
Now we are using uplc rust package version 1.0.14-alpha, you can update this version and rebuild by updating this version in Cargo.toml file.
```
uplc = { version = "1.0.14-alpha" }
```
## Special Thanks
Special thanks to Aiken for providing the library for decoding flat data. Now, we can build it to WebAssembly and use it in the Cardano Explorer.
17 changes: 17 additions & 0 deletions lib/pkg/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "uplc-js",
"collaborators": [
"sotatek"
],
"version": "0.1.0",
"files": [
"uplc_js_bg.wasm",
"uplc_js.js",
"uplc_js.d.ts"
],
"module": "uplc_js.js",
"types": "uplc_js.d.ts",
"sideEffects": [
"./snippets/*"
]
}
39 changes: 39 additions & 0 deletions lib/pkg/uplc_js.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* tslint:disable */
/* eslint-disable */
/**
* @param {string} flat
* @returns {string}
*/
export function decode(flat: string): string;

export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;

export interface InitOutput {
readonly memory: WebAssembly.Memory;
readonly decode: (a: number, b: number, c: number) => void;
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
readonly __wbindgen_malloc: (a: number, b: number) => number;
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
}

export type SyncInitInput = BufferSource | WebAssembly.Module;
/**
* Instantiates the given `module`, which can either be bytes or
* a precompiled `WebAssembly.Module`.
*
* @param {SyncInitInput} module
*
* @returns {InitOutput}
*/
export function initSync(module: SyncInitInput): InitOutput;

/**
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
* for everything else, calls `WebAssembly.instantiate` directly.
*
* @param {InitInput | Promise<InitInput>} module_or_path
*
* @returns {Promise<InitOutput>}
*/
export default function __wbg_init(module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
Loading

0 comments on commit 6faa386

Please sign in to comment.