Skip to content
Open
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
22 changes: 12 additions & 10 deletions Editor/BlockmakerBuildKeyStripper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ public class BlockmakerBuildKeyStripper : IPreprocessBuildWithReport, IPostproce
{
public int callbackOrder => 0;

// Distinct from any game-local stripper so the two can coexist safely
// (each captures/restores only its own SessionState).
private const string StateKey = "blockmaker.sdk.strippedApiKeys";
// Stash lives in Library/ (gitignored, survives editor restarts) rather
// than SessionState: a failed or cancelled batchmode build exits the
// editor session, and a SessionState stash would be lost — permanently
// blanking every config's key. Distinct file from any game-local
// stripper so the two coexist safely.
private static string StashPath => System.IO.Path.Combine(
System.IO.Path.GetDirectoryName(Application.dataPath), "Library", "blockmaker-stripped-keys.json");

[System.Serializable] private class Entry { public string path; public string key; }
[System.Serializable] private class Entries { public List<Entry> items = new List<Entry>(); }
Expand All @@ -43,13 +47,10 @@ public void OnPreprocessBuild(BuildReport report)
if (saved.items.Count > 0)
{
AssetDatabase.SaveAssets();
SessionState.SetString(StateKey, JsonUtility.ToJson(saved));
System.IO.File.WriteAllText(StashPath, JsonUtility.ToJson(saved));
Debug.LogWarning($"[Blockmaker] Stripped the dev apiKey from {saved.items.Count} BlockmakerConfig(s) for this build — it will not ship. Restored automatically after the build.");
}
else
{
SessionState.EraseString(StateKey);
}

}

public void OnPostprocessBuild(BuildReport report) => RestoreKeys();
Expand All @@ -64,7 +65,8 @@ [InitializeOnLoadMethod] private static void RestoreOnLoad()

private static void RestoreKeys()
{
var json = SessionState.GetString(StateKey, "");
if (!System.IO.File.Exists(StashPath)) return;
var json = System.IO.File.ReadAllText(StashPath);
if (string.IsNullOrEmpty(json)) return;

var saved = JsonUtility.FromJson<Entries>(json);
Expand All @@ -81,7 +83,7 @@ private static void RestoreKeys()
}
AssetDatabase.SaveAssets();
}
SessionState.EraseString(StateKey);
System.IO.File.Delete(StashPath);
}
}
}
14 changes: 7 additions & 7 deletions Plugins/WebGL/BlockmakerWalletBridge.jslib
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ mergeInto(LibraryManager.library, {
if (window._bmSignClientPromise && !window._bmSignClientFailed) return window._bmSignClientPromise;
window._bmSignClientFailed = false;
window._bmSignClientPromise =
import('https://cdn.jsdelivr.net/npm/@walletconnect/sign-client@2.17.3/+esm')
(new Function('return import(\"https://cdn.jsdelivr.net/npm/@walletconnect/sign-client@2.17.3/+esm\")'))()
.then(function(mod) {
var SC = mod.SignClient || (mod.default && mod.default.SignClient);
if (!SC) throw new Error('SignClient not found in module');
Expand Down Expand Up @@ -570,7 +570,7 @@ mergeInto(LibraryManager.library, {
if (window._bmPeraConnectPromise && !window._bmPeraConnectFailed) return window._bmPeraConnectPromise;
window._bmPeraConnectFailed = false;
window._bmPeraConnectPromise =
import('https://cdn.jsdelivr.net/npm/@perawallet/connect@1.5.2/+esm')
(new Function('return import(\"https://cdn.jsdelivr.net/npm/@perawallet/connect@1.5.2/+esm\")'))()
.then(function(mod) {
var PWC = mod.PeraWalletConnect || (mod.default && mod.default.PeraWalletConnect);
if (!PWC) throw new Error('PeraWalletConnect not found in module');
Expand All @@ -592,7 +592,7 @@ mergeInto(LibraryManager.library, {
if (window._bmAlgosdkPromise && !window._bmAlgosdkFailed) return window._bmAlgosdkPromise;
window._bmAlgosdkFailed = false;
window._bmAlgosdkPromise =
import('https://cdn.jsdelivr.net/npm/algosdk@3.5.2/+esm')
(new Function('return import(\"https://cdn.jsdelivr.net/npm/algosdk@3.5.2/+esm\")'))()
.then(function(mod) {
var sdk = (mod && mod.decodeUnsignedTransaction) ? mod
: (mod.default && mod.default.decodeUnsignedTransaction) ? mod.default
Expand Down Expand Up @@ -909,8 +909,8 @@ mergeInto(LibraryManager.library, {
if (window._bmMagicPromise && !window._bmMagicFailed) return window._bmMagicPromise;
window._bmMagicFailed = false;
window._bmMagicPromise = Promise.all([
import('https://cdn.jsdelivr.net/npm/magic-sdk@33.7.1/+esm'),
import('https://cdn.jsdelivr.net/npm/@magic-ext/algorand@26.2.0/+esm')
(new Function('return import(\"https://cdn.jsdelivr.net/npm/magic-sdk@33.7.1/+esm\")'))(),
(new Function('return import(\"https://cdn.jsdelivr.net/npm/@magic-ext/algorand@26.2.0/+esm\")'))()
]).then(function(mods) {
var Magic = mods[0].Magic || (mods[0].default && mods[0].default.Magic) || mods[0].default;
var AlgorandExtension = mods[1].AlgorandExtension || (mods[1].default && mods[1].default.AlgorandExtension) || mods[1].default;
Expand Down Expand Up @@ -1146,13 +1146,13 @@ mergeInto(LibraryManager.library, {
if (window._bmXChainPromise && !window._bmXChainFailed) return window._bmXChainPromise;
window._bmXChainFailed = false;
window._bmXChainPromise =
import('https://cdn.jsdelivr.net/npm/@algorandfoundation/xchain-js/+esm')
(new Function('return import(\"https://cdn.jsdelivr.net/npm/@algorandfoundation/xchain-js/+esm\")'))()
.then(function(mod) {
window._bmXChain = mod;
return mod;
})
.catch(function() {
return import('https://cdn.jsdelivr.net/npm/algo-models/+esm')
return (new Function('return import(\"https://cdn.jsdelivr.net/npm/algo-models/+esm\")'))()
.then(function(mod) {
window._bmXChain = mod;
return mod;
Expand Down