Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
e0d6f89
support Sepolia
jfschwarz Jul 15, 2025
92991d4
add launch pilot menu item
jfschwarz Jul 15, 2025
7d9c220
launch pilot and start callback server
jfschwarz Jul 16, 2025
bbeb3dd
select token balances for spoofing
jfschwarz Jul 17, 2025
12cd647
fix rpc requests
jfschwarz Aug 14, 2025
e6e6b4c
solidify Pilot Connect callback server
jfschwarz Aug 20, 2025
17deddd
response callback mechanism
jfschwarz Aug 25, 2025
66bfad8
show transactions captured from pilot
jfschwarz Aug 29, 2025
6d139e6
use a more random demo address
jfschwarz Aug 29, 2025
8effde6
sketch out main actions. plug it in temporarily to main meny
cristovaoth Oct 21, 2025
37e59b5
update Mock Mech bytecode
cristovaoth Oct 21, 2025
e514cdc
sketching the four main actions
cristovaoth Oct 22, 2025
313ead6
Include test exec in main-ui
cristovaoth Oct 23, 2025
26036ec
bump dependencies
cristovaoth Oct 23, 2025
b7e4856
Use a simple unshield for Mech deposit
cristovaoth Oct 23, 2025
7bc2311
adjust NFT address
cristovaoth Oct 23, 2025
43218f6
update nft contract address
cristovaoth Oct 23, 2025
80d28a9
really mint the real nft
cristovaoth Oct 23, 2025
e57ccab
Improve the temporary deploy and mint process
cristovaoth Oct 23, 2025
c26a997
use real mech
cristovaoth Oct 23, 2025
28c3d20
Refactor mech deployment architecture
cristovaoth Oct 23, 2025
52d916b
rename folders container core primitives, and ui entrypoints
cristovaoth Oct 24, 2025
aa83839
bring back deploy
cristovaoth Oct 24, 2025
aa24939
Extract mint and deploy. Require mint to be first done and shielded, …
cristovaoth Oct 24, 2025
0b0d379
adjust params for core primitives
cristovaoth Oct 24, 2025
1362a50
adjust mech menu flow
jfschwarz Oct 27, 2025
3c28412
adjust todo
jfschwarz Oct 27, 2025
1146af6
use old promise syntax
jfschwarz Oct 27, 2025
fc0fc29
consolidate mech operations into unified operate function with lazy d…
cristovaoth Oct 27, 2025
8523735
make encoding inside execute a little bit more explicit
cristovaoth Oct 28, 2025
c7821e0
connect UI with new mech functions
jfschwarz Nov 6, 2025
48481b5
improve copy
jfschwarz Nov 6, 2025
71ec3a3
breakdown mech operations into separate deposit and execute functions
cristovaoth Nov 8, 2025
9d3d847
bring back operateMech
cristovaoth Nov 8, 2025
63518b2
subtract fees from spoofed balances
jfschwarz Nov 8, 2025
9b11574
npm audit fix
jfschwarz Nov 8, 2025
371426f
launch pilot with actual mech address
jfschwarz Nov 8, 2025
bbf06b3
cleanup menus
jfschwarz Nov 11, 2025
1ef9966
fix: use `MECH_SALT` in `predictMechAddress()`
auryn-macmillan Nov 12, 2025
38b46d8
don't swallow execution errors
jfschwarz Nov 13, 2025
586d3cc
fix small menu navigation issue
jfschwarz Nov 13, 2025
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
3 changes: 1 addition & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
],
"arrow-body-style": 0,
"import/extensions": 0,
"no-unused-vars": 0, // disable for now lots of these too
"no-use-before-define": 1,
"no-unused-vars": 0, // disable for now lots of these too
"import/prefer-default-export": 0,
"import/no-unresolved": 0,
"no-restricted-syntax": 0,
Expand Down
13,223 changes: 7,348 additions & 5,875 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"author": "anon",
"license": "LGPL-3.0-or-later",
"devDependencies": {
"@graphql-tools/utils": "^9.2.1",
"@release-it/conventional-changelog": "^7.0.0",
"@types/level-js": "4.0.2",
"@types/leveldown": "4.0.3",
Expand All @@ -60,19 +59,21 @@
"typescript": "5.1.6"
},
"dependencies": {
"@gnosis-guild/zodiac-core": "^3.0.0",
"@libp2p/interface": "1.3.0",
"@railgun-community/cookbook": "2.10.3",
"@railgun-community/cookbook": "2.12.0",
"@railgun-community/curve25519-scalarmult-rsjs": "0.2.4",
"@railgun-community/poseidon-hash-rsjs": "1.0.1",
"@railgun-community/shared-models": "7.6.1",
"@railgun-community/waku-broadcaster-client-node": "8.2.7",
"@railgun-community/wallet": "10.4.1",
"@railgun-community/shared-models": "8.0.0",
"@railgun-community/waku-broadcaster-client-node": "8.4.0",
"@railgun-community/wallet": "10.8.0",
"bn": "1.0.5",
"colors": "^1.4.0",
"enquirer": "2.3.6",
"ethers": "6.13.1",
"level-js": "6.1.0",
"leveldown": "6.1.1",
"open": "10.2.0",
"snarkjs": "0.7.0"
},
"packageManager": "yarn@1.22.19"
Expand Down
22 changes: 13 additions & 9 deletions src/balance/balance-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export const getPrivateERC20BalancesForChain = (
return [];
}
const erc20Addresses = Object.keys(cache);

const balances: RailgunDisplayBalance[] = [];
erc20Addresses.map(async (tokenAddress) => {
const { name, symbol, decimals } = await getTokenInfo(
Expand Down Expand Up @@ -185,8 +186,10 @@ export const getDisplayStringFromBalance = (
return balanceDisplayString;
};

export const getPrivateDisplayBalances = async (chainName: NetworkName, bucketType: RailgunWalletBalanceBucket) => {

export const getPrivateDisplayBalances = async (
chainName: NetworkName,
bucketType: RailgunWalletBalanceBucket,
) => {
const CHAIN_NAME = configDefaults.networkConfig[chainName].name.toUpperCase();
const display: string[] = [];

Expand All @@ -195,18 +198,19 @@ export const getPrivateDisplayBalances = async (chainName: NetworkName, bucketTy
? await getPrivateERC20BalancesForChain(chainName, bucketType)
: await getPublicERC20BalancesForChain(chainName, true);


if(bucketType !== RailgunWalletBalanceBucket.Spendable){
if(balances.length === 0){
return ""
if (bucketType !== RailgunWalletBalanceBucket.Spendable) {
if (balances.length === 0) {
return "";
}
if(!isPrivate){
if (!isPrivate) {
// if not private, only show set of balances once. dont add header.
return ""
return "";
}
}
const balanceType = isPrivate ? "PRIVATE" : "PUBLIC";
const header = `${CHAIN_NAME.green} ${ isPrivate ? bucketType.green : ''} ${balanceType} BALANCES`;
const header = `${CHAIN_NAME.green} ${
isPrivate ? bucketType.green : ""
} ${balanceType} BALANCES`;
const headLen = stripColors(header).length;
display.push("");
const headerLine = `${header}`;
Expand Down
11 changes: 7 additions & 4 deletions src/engine/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ export const isEngineRunning = () => {
};

const interceptLog = {
log: (log: string) => { },
log: (log: string) => {
console.log(log);
},
error: (err: any) => {
console.log(err.message);
console.log(err);
},
};

Expand Down Expand Up @@ -197,8 +199,9 @@ export const getProviderPromptOptions = (chainName: NetworkName) => {
const providerEnabled = customProviders[provider];
return {
name: provider,
message: `[${providerEnabled ? "Enabled ".green.dim : "Disabled".yellow.dim
}] ${provider}`,
message: `[${
providerEnabled ? "Enabled ".green.dim : "Disabled".yellow.dim
}] ${provider}`,
};
});

Expand Down
52 changes: 52 additions & 0 deletions src/mech/deployments.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import {
RailgunProxyContract,
RelayAdaptContract,
} from "@railgun-community/shared-models";

import { getCurrentNetwork } from "../engine/engine";
import configDefaults from "../config/config-defaults";

import { encodeMechCreate, predictMechAddress } from "./encode";

// universal addresses:
const erc6551Factory = "0x000000006551c19487814612e58fe06813775758";
const mechMastercopy = "0xc62046fbbcf02725949afeab16dcf75f5066e2bb";
const railgunNeuralLink = "0xd53c76d176c45f93bd86da63842abbc6d467c3ea";

function chainId() {
const { chainId } = configDefaults.networkConfig[getCurrentNetwork()];
return chainId;
}

export default {
railgunSmartWallet: () => ({
address: RailgunProxyContract[getCurrentNetwork()].toLowerCase(),
}),
relayAdapt: () => ({
address: RelayAdaptContract[getCurrentNetwork()].toLowerCase(),
}),
railgunNeuralLink: railgunNeuralLink as `0x${string}`,
mech: (tokenId: bigint) => ({
address: predictMechAddress({
factory: erc6551Factory,
chainId: chainId(),
mastercopy: mechMastercopy,
tokenAddress: railgunNeuralLink,
tokenId,
}) as `0x${string}`,
tokenAddress: railgunNeuralLink as `0x${string}`,
tokenId,
}),
};

export function mechDeploymentTx(tokenId: bigint) {
return {
to: erc6551Factory,
data: encodeMechCreate({
mastercopy: mechMastercopy,
chainId: chainId(),
tokenAddress: railgunNeuralLink,
tokenId,
}),
};
}
116 changes: 116 additions & 0 deletions src/mech/encode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import {
AbiCoder,
concat,
getCreate2Address,
Interface,
keccak256,
ZeroHash,
} from "ethers";

const MECH_SALT =
"0x0000000000000000000000000000000000000000000000000000000000000bad";

export function encodeMechCreate({
mastercopy,
chainId,
tokenAddress,
tokenId,
}: {
mastercopy: string;
chainId: number | bigint;
tokenAddress: string;
tokenId: bigint;
}) {
const iface = new Interface([
"function createAccount(address implementation, bytes32 salt, uint256 chainId, address tokenContract, uint256 tokenId) returns (address)",
]);

return iface.encodeFunctionData("createAccount", [
mastercopy,
MECH_SALT,
chainId,
tokenAddress,
tokenId,
]);
}

export function predictMechAddress({
factory,
chainId,
mastercopy,
tokenAddress,
tokenId,
}: {
factory: string;
chainId: number;
mastercopy: string;
tokenAddress: string;
tokenId: bigint;
}): string {
const eip6551ProxyCreationBytecode = concat([
"0x3d60ad80600a3d3981f3363d3d373d3d3d363d73",
mastercopy,
"0x5af43d82803e903d91602b57fd5bf3",
AbiCoder.defaultAbiCoder().encode(
["bytes32", "uint256", "address", "uint256"],
[MECH_SALT, chainId, tokenAddress, tokenId],
),
]);
return getCreate2Address(
factory,
MECH_SALT,
keccak256(eip6551ProxyCreationBytecode),
);
}

export function encodeMechExecute({
to,
value,
data,
operation,
}: {
to: string;
value?: string | bigint | number | undefined | null;
data: string;
operation?: number;
}) {
const iface = new Interface([
"function execute(address to, uint256 value, bytes calldata data, uint8 operation) public payable returns (bytes memory returnData)",
]);
return iface.encodeFunctionData("execute", [
to,
BigInt(value || 0),
data,
operation || 0,
]);
}

export function encodeMint() {
const iface = new Interface(["function mint() external"]);

return iface.encodeFunctionData("mint");
}

export function encodeTranfer(to: string, amount: bigint | number) {
const iface = new Interface([
"function transfer(address to, uint256 amount)",
]);

return iface.encodeFunctionData("transfer", [to, amount]);
}

export function encodeTranferFrom(from: string, to: string, tokenId: bigint) {
const iface = new Interface([
"function transferFrom(address from, address to, uint256 tokenId)",
]);

return iface.encodeFunctionData("transferFrom", [from, to, tokenId]);
}

export function encodeApprove(to: string, tokenId: bigint) {
const iface = new Interface([
"function approve(address to, uint256 tokenId)",
]);

return iface.encodeFunctionData("approve", [to, tokenId]);
}
Loading