Skip to content

Instantly share code, notes, and snippets.

View 0xSamWitch's full-sized avatar

Sam Witch 0xSamWitch

View GitHub Profile
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0;
interface INFTVaultFactory {
struct CreationInfo {
bool createdHere;
uint16 version;
}
function creationInfo(address) external view returns (CreationInfo memory);
if (pathOrBuffer === pck) {
return Promise.resolve();
}
this.preloadedFiles = [ { path: pck, buffer:pckBuffer, } ];
const pck = "Platformer 2D.pck";
this.preloadedFiles = [ { path: pck, buffer:pckBuffer, } ];
this.preload = function (pathOrBuffer, destPath, fileSize) {
let buffer = null;
if (typeof pathOrBuffer === 'string') {
if (pathOrBuffer === pck) {
return Promise.resolve();
}
const me = this;
return this.loadPromise(pathOrBuffer, fileSize).then(function (buf) {
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
// Use a lookup table to find the index.
const lookup = new Uint8Array(256);
for (let i = 0; i < chars.length; i++) {
lookup[chars.charCodeAt(i)] = i;
}
function decode(base64) {
var bufferLength = base64.length * 0.75,
len = base64.length,
i,
const fs = require("fs");
// Replace as necessary
const NAME = "Platformer 2D";
let code = fs.readFileSync(`./${NAME}.wasm`);
fs.writeFileSync("base64.wasm", code.toString("base64"));
code = fs.readFileSync(`./${NAME}.pck`);
fs.writeFileSync("base64.pck", code.toString("base64"));
const wasmCode = "<copy contents of base64.wasm>";
const wasmBuffer = decode(wasmCode);
const pckCode = "<copy contents of base64.pck>";
const pckBuffer = decode(pckCode);
Engine.load = function (basePath, size) {
...
return loadPromise;
};
Engine.load = function (basePath, size) {
if (loadPromise == null) {
loadPath = basePath;
loadPromise = Promise.resolve({
clone: () => ({
body: wasmBuffer
}),
});
}
};
this.preloadedFiles = [];
this.preload = function (pathOrBuffer, destPath, fileSize) {
let buffer = null;
return Promise.reject(new Error('Invalid object for preloading'));
};