Skip to content

Commit

Permalink
fix: web4 bundle/wasm32-wasip1 (#34)
Browse files Browse the repository at this point in the history
* fix web4 bundle
switch to mainnet

* wasm32-wasip1

* wasm32-wasi
  • Loading branch information
petersalomonsen authored Jan 25, 2025
1 parent 91c7383 commit f0ea09e
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 151 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,7 @@ jobs:
echo "$(pwd)/binaryen-version_116/bin" >> $GITHUB_PATH
echo "$(pwd)/wabt-1.0.35/bin" >> $GITHUB_PATH
echo "$(pwd)/bin" >> $GITHUB_PATH
rustup target add wasm32-wasip1
rustup target add wasm32-wasi
rustup target add wasm32-wasip1
rustup target add wasm32-unknown-unknown
- name: Build Fungible Token contract
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-ai-proxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
run: |
curl -fsSL https://developer.fermyon.com/downloads/install.sh | bash
sudo mv spin /usr/local/bin/
rustup target add wasm32-wasi
rustup target add wasm32-wasip1
cargo install cargo-component --locked
spin plugin install -y -u https://github.com/fermyon/spin-test/releases/download/canary/spin-test.json
- name: Check formatting
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-aiproxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
run: |
curl -fsSL https://developer.fermyon.com/downloads/install.sh | bash
sudo mv spin /usr/local/bin/
rustup target add wasm32-wasi
rustup target add wasm32-wasip1
cargo install cargo-component --locked
spin plugin install -y -u https://github.com/fermyon/spin-test/releases/download/canary/spin-test.json
- name: Check formatting
Expand Down
19 changes: 0 additions & 19 deletions .gitpod.yml

This file was deleted.

6 changes: 3 additions & 3 deletions examples/aiproxy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ The first command `yarn aiproxy:web4bundle` takes the `index.html` and `main.js`
Note when creating the `JSON_ARGS`, that the `aiconversation.js` and `web4.js` files are concatenated and inserted into the `javascript` property of the function call args. In the file [aiconversation.js](../fungibletoken/e2e/aiconversation.js), there is the placeholder `REPLACE_REFUND_SIGNATURE_PUBLIC_KEY`, which needs to be replaced with the public key corresponding to the signing key passed to the AI proxy above. This replacement is also done in the command snippet below.

```bash
export NETWORK_ID=testnet
export RPC_URL=https://rpc.testnet.near.org
export NETWORK_ID=mainnet
export RPC_URL=https://rpc.mainnet.near.org
export AI_PROXY_BASEURL=https://openai-proxy-zoukmtuw.fermyon.app
yarn aiproxy:web4bundle
export JSON_ARGS=$(cat ../fungibletoken/e2e/aiconversation.js web4.js | sed "s/REPLACE_REFUND_SIGNATURE_PUBLIC_KEY/${REPLACE_REFUND_SIGNATURE_PUBLIC_KEY}/g" | jq -Rs '{javascript: .}')
near contract call-function as-transaction arizcredits.testnet post_javascript json-args $JSON_ARGS prepaid-gas '100.0 Tgas' attached-deposit '0 NEAR' sign-as arizcredits.testnet network-config testnet sign-with-keychain send
near contract call-function as-transaction arizcredits.near post_javascript json-args $JSON_ARGS prepaid-gas '100.0 Tgas' attached-deposit '0 NEAR' sign-as arizcredits.near network-config mainnet sign-with-keychain send
```

13 changes: 8 additions & 5 deletions examples/aiproxy/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
import html from '@web/rollup-plugin-html';
import { rollupPluginHTML as html } from '@web/rollup-plugin-html';
import { terser } from 'rollup-plugin-terser';
import { readFileSync, writeFileSync } from 'fs';

const { AI_PROXY_BASEURL, RPC_URL, NETWORK_ID } = process.env;

if (!AI_PROXY_BASEURL) {
throw ('Environment variable AI_PROXY_BASEURL not set. Must be set to the base URL of where the AI proxy is hosted');
console.error('Environment variable AI_PROXY_BASEURL not set. Must be set to the base URL of where the AI proxy is hosted');
process.exit(1);
}
if (!RPC_URL) {
throw ('Environment variable RPC_URL not set. Must be set to the NEAR RPC node URL');
console.error('Environment variable RPC_URL not set. Must be set to the NEAR RPC node URL');
process.exit(1);
}
if (!NETWORK_ID) {
throw ('Environment variable NETWORK_ID not set. Must be set to the NEAR protocol network id ( e.g. mainnet, testnet )');
console.error('Environment variable NETWORK_ID not set. Must be set to the NEAR protocol network id ( e.g. mainnet, testnet )');
process.exit(1);
}

export default {
input: ['./web/index.html'],
input: './web/index.html',
output: { dir: 'dist' },
plugins: [html({ minify: true }), terser(), {
name: 'inline-js',
Expand Down
4 changes: 2 additions & 2 deletions examples/aiproxy/spin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ route = "/..."
component = "openai-proxy"

[component.openai-proxy]
source = "openai-proxy/target/wasm32-wasi/release/openai_proxy.wasm"
source = "openai-proxy/target/wasm32-wasip1/release/openai_proxy.wasm"
allowed_outbound_hosts = ["https://api.openai.com:443", "https://*.openai.azure.com", "https://rpc.testnet.near.org:443", "https://rpc.mainnet.near.org:443", "http://localhost:14500", "http://127.0.0.1:3001"]
key_value_stores = ["default"]

[component.openai-proxy.build]
command = "cargo build --target wasm32-wasi --release"
command = "cargo build --target wasm32-wasip1 --release"
workdir = "openai-proxy"
watch = ["src/**/*.rs", "Cargo.toml"]

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"dotenv": "^16.4.7",
"http-server": "^14.1.1",
"near-workspaces": "4.0.0",
"rollup": "^4.29.1",
"rollup": "^4.31.0",
"rollup-plugin-terser": "^7.0.2"
},
"dependencies": {}
Expand Down
Loading

0 comments on commit f0ea09e

Please sign in to comment.