Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 49 additions & 46 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,51 +1,54 @@
{
"name": "Cartridge Marketplace",
"slug": "cartridge-marketplace",
"version": "1.0.0",
"web": {
"favicon": "./assets/favicon.png"
},
"experiments": {
"tsconfigPaths": true
},
"plugins": [
[
"expo-font",
{
"fonts": [
"node_modules/@expo-google-fonts/inter/400Regular/Inter_400Regular.ttf",
"node_modules/@expo-google-fonts/inter/500Medium/Inter_500Medium.ttf",
"node_modules/@expo-google-fonts/inter/600SemiBold/Inter_600SemiBold.ttf",
"node_modules/@expo-google-fonts/inter/700Bold/Inter_700Bold.ttf",
"node_modules/@expo-google-fonts/ibm-plex-mono/400Regular/IBMPlexMono_400Regular.ttf",
"node_modules/@expo-google-fonts/ibm-plex-mono/500Medium/IBMPlexMono_500Medium.ttf",
"node_modules/@expo-google-fonts/ibm-plex-mono/600SemiBold/IBMPlexMono_600SemiBold.ttf",
"node_modules/@expo-google-fonts/ibm-plex-mono/700Bold/IBMPlexMono_700Bold.ttf"
]
}
]
],
"orientation": "portrait",
"icon": "./assets/icon.png",
"userInterfaceStyle": "light",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"assetBundlePatterns": ["**/*"],
"ios": {
"supportsTablet": true,
"bundleIdentifier": "com.cartridge.marketplace",
"name": "Cartridge Marketplace",
"slug": "cartridge-marketplace",
"version": "1.0.0",
"web": {
"favicon": "./assets/favicon.png"
},
"experiments": {
"tsconfigPaths": true
},
"plugins": [
[
"expo-font",
{
"fonts": [
"node_modules/@expo-google-fonts/inter/400Regular/Inter_400Regular.ttf",
"node_modules/@expo-google-fonts/inter/500Medium/Inter_500Medium.ttf",
"node_modules/@expo-google-fonts/inter/600SemiBold/Inter_600SemiBold.ttf",
"node_modules/@expo-google-fonts/inter/700Bold/Inter_700Bold.ttf",
"node_modules/@expo-google-fonts/ibm-plex-mono/400Regular/IBMPlexMono_400Regular.ttf",
"node_modules/@expo-google-fonts/ibm-plex-mono/500Medium/IBMPlexMono_500Medium.ttf",
"node_modules/@expo-google-fonts/ibm-plex-mono/600SemiBold/IBMPlexMono_600SemiBold.ttf",
"node_modules/@expo-google-fonts/ibm-plex-mono/700Bold/IBMPlexMono_700Bold.ttf"
]
}
],
"react-native-webassembly"
],
"orientation": "portrait",
"icon": "./assets/icon.png",
"userInterfaceStyle": "light",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true,
"bundleIdentifier": "com.cartridge.marketplace",
"associatedDomains": [
"webcredentials:x.cartridge.gg"
]
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#ffffff"
},
"package": "com.cartridge.marketplace"
}
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#ffffff"
},
"package": "com.cartridge.marketplace"
}
}
21 changes: 12 additions & 9 deletions app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ import { View } from "react-native";
import { Button, SonnerToaster, Text } from "#components";

export default function RootScreen() {
return (
<View className="flex-1 items-center justify-center bg-background-100 gap-4">
<Text className="text-2xl font-bold">Cartridge Marketplace</Text>
<Button onPress={() => router.push("/connect")}>
<Text>Connect</Text>
</Button>
<SonnerToaster />
</View>
);
return (
<View className="flex-1 items-center justify-center bg-background-100 gap-4">
<Text className="text-2xl font-bold">Cartridge Marketplace</Text>
<Button onPress={() => router.push("/connect")}>
<Text>Connect</Text>
</Button>
<Button onPress={() => router.push("/wasm")}>
<Text>Wasm</Text>
</Button>
<SonnerToaster />
</View>
);
}
61 changes: 61 additions & 0 deletions app/wasm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { useEffect, useState } from "react";
import { View } from "react-native";
import * as WebAssembly from 'react-native-webassembly';
import { Text } from "#components";
import axios from "axios";

// Alternative approach: Bundle WASM locally
// 1. Download the WASM file and place it in your assets folder
// 2. Import it directly:
// import wasmFile from '../assets/account_wasm_bg.wasm';

export default function WasmScreen() {
// const [controller, setController] = useState<WebAssembly.WebassemblyInstantiateResult<any> | null>(null);
const [error, setError] = useState<string | null>(null);

useEffect(() => {
async function init() {
try {
// const bytes = await fetchWasm("https://unpkg.com/@cartridge/[email protected]/pkg-controller/account_wasm_bg.wasm");
const bytes = await fetchWasm("https://github.com/JunichiSugiura/controller-rs/raw/feat/no-modules/account-wasm/controller.wasm")
console.log(bytes)
const wasm = await WebAssembly.instantiate<{
cartridgeaccount_new: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => void;
}>(bytes);
const res = wasm.instance.exports.cartridgeaccount_new(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13);
console.log(res)
} catch (err) {
console.error('Error fetching WASM:', err);
setError(err instanceof Error ? err.message : 'Unknown error');
throw err;
}
};

init();
}, []);

// console.log(Object.keys(controller?.instance?.exports ?? {}))

return (
<View>
{error && (
<Text style={{ color: 'red' }}>
Error: {error}
</Text>
)}
<Text>
{/* {JSON.stringify(Object.keys(controller?.instance?.exports ?? {}))} */}
</Text>
</View>
);
}

export async function fetchWasm(uri: string) {
const { data: bufferSource } = await axios({
url: uri,
method: 'get',
responseType: 'arraybuffer',
});

return bufferSource;
}
10 changes: 9 additions & 1 deletion bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"@rn-primitives/slot": "^1.2.0",
"@rn-primitives/tooltip": "^1.2.0",
"@rn-primitives/utils": "^1.2.0",
"axios": "^1.11.0",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"expo": "^53.0.20",
Expand All @@ -75,6 +76,7 @@
"react-native-svg": "15.11.2",
"react-native-toast-message": "^2.3.0",
"react-native-web": "^0.20.0",
"react-native-webassembly": "^0.3.3",
"sonner": "^2.0.5",
"sonner-native": "^0.21.0",
"starknet": "^7.6.2",
Expand Down
Loading