Skip to content
Merged
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
32 changes: 16 additions & 16 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,36 @@ bun install

### Bridge Operations

- `bun cli sol onchain bridge wrap-token` - Create wrapped version of Base token on Solana
- `bun cli sol onchain bridge bridge-sol` - Bridge SOL from Solana to Base
- `bun cli sol onchain bridge bridge-spl` - Bridge SPL tokens from Solana to Base
- `bun cli sol onchain bridge bridge-wrapped-token` - Bridge wrapped tokens back to Base
- `bun cli sol onchain bridge bridge-call` - Bridge a call from Solana to Base
- `bun cli sol onchain bridge prove-message` - Prove message from Base and relay to Solana
- `bun cli sol onchain bridge relay-message` - Relay message from Base
- `bun cli sol bridge wrap-token` - Create wrapped version of Base token on Solana
- `bun cli sol bridge bridge-sol` - Bridge SOL from Solana to Base
- `bun cli sol bridge bridge-spl` - Bridge SPL tokens from Solana to Base
- `bun cli sol bridge bridge-wrapped-token` - Bridge wrapped tokens back to Base
- `bun cli sol bridge bridge-call` - Bridge a call from Solana to Base
- `bun cli sol bridge prove-message` - Prove message from Base and relay to Solana
- `bun cli sol bridge relay-message` - Relay message from Base

### Program Management

- `bun cli sol program build` - Build Solana program
- `bun cli sol program deploy` - Deploy Solana program
- `bun cli sol program generate-idl` - Generate program IDL
- `bun cli sol program generate-client` - Generate TypeScript client
- `bun cli sol build` - Build Solana program
- `bun cli sol deploy` - Deploy Solana program
- `bun cli sol generate-idl` - Generate programIDL
- `bun cli sol generate-client` - Generate TypeScript client

### SPL Token Operations

- `bun cli sol onchain spl create-mint` - Create new SPL token mint
- `bun cli sol onchain spl create-ata` - Create Associated Token Account
- `bun cli sol onchain spl mint` - Mint SPL tokens
- `bun cli sol spl create-mint` - Create new SPL token mint
- `bun cli sol spl create-ata` - Create Associated Token Account
- `bun cli sol spl mint` - Mint SPL tokens

### Utilities

- `bun cli sol generate-keypair` - Generate new Solana keypair
- `bun cli utils pubkey-to-bytes32` - Convert Solana pubkey to bytes32
- `bun cli sol pubkey-to-bytes32` - Convert Solana pubkey to bytes32

## Non-Interactive Mode

All commands support non-interactive execution by providing required arguments:

```bash
bun cli sol onchain bridge bridge-sol --cluster devnet --release prod --to 0x1234567890123456789012345678901234567890 --amount 10 --payer-kp config
bun cli sol bridge bridge-sol --deploy-env testnet-prod --to 0x1234567890123456789012345678901234567890 --amount 10 --payer-kp config --pay-for-relay
```
9 changes: 0 additions & 9 deletions scripts/bun.lock

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

6 changes: 3 additions & 3 deletions scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"type": "module",
"private": true,
"scripts": {
"cli": "bun run src/bin.ts"
"cli": "bun run src/bin.ts",
"postinstall": "cd ../clients/ts && bun install && bun run build"
},
"devDependencies": {
"@codama/nodes-from-anchor": "1.2.9",
Expand All @@ -20,8 +21,7 @@
"@types/bun": "latest",
"viem": "2.38.0",
"zod": "4.1.12",
"@clack/prompts": "0.11.0",
"@base/bridge": "file:../clients/ts"
"@clack/prompts": "0.11.0"
},
"peerDependencies": {
"typescript": "5.9.3"
Expand Down
10 changes: 1 addition & 9 deletions scripts/src/commands/sol/bridge/sol-vault.command.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { Command } from "commander";

import {
getOrPromptEvmAddress,
getOrPromptSolanaAddress,
validateAndExecute,
} from "@internal/utils/cli";
import { argsSchema, handleSolVault } from "./sol-vault.handler";

type CommanderOptions = {
bridgeProgram?: string;
remoteToken?: string;
};

async function collectInteractiveOptions(
Expand All @@ -22,18 +20,12 @@ async function collectInteractiveOptions(
"Enter bridge program address (Solana address)"
);

opts.remoteToken = await getOrPromptEvmAddress(
opts.remoteToken,
"Enter remote token address (Base EVM address)"
);

return opts;
}

export const solVaultCommand = new Command("sol-vault")
.description("Display SOL vault PDA for a given remote token")
.description("Display SOL vault PDA")
.option("--bridge-program <address>", "Bridge program address on Solana")
.option("--remote-token <address>", "Remote token address on Base")
.action(async (options) => {
const opts = await collectInteractiveOptions(options);
await validateAndExecute(argsSchema, opts, handleSolVault);
Expand Down
13 changes: 1 addition & 12 deletions scripts/src/commands/sol/bridge/sol-vault.handler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { z } from "zod";
import { isAddress as isEvmAddress, type Address as EvmAddress } from "viem";
import {
address as solanaAddress,
isAddress as isSolanaAddress,
Expand All @@ -15,12 +14,6 @@ export const argsSchema = z.object({
message: "Value must be a valid Solana address",
})
.transform((value) => solanaAddress(value)),
remoteToken: z
.string()
.refine((value) => isEvmAddress(value), {
message: "Invalid Base/Ethereum address format",
})
.transform((value) => value as EvmAddress),
});

type Args = z.infer<typeof argsSchema>;
Expand All @@ -30,12 +23,8 @@ export async function handleSolVault(args: Args): Promise<void> {
logger.info("--- SOL Vault PDA Lookup ---");

logger.info(`Bridge Program: ${args.bridgeProgram}`);
logger.info(`Remote token: ${args.remoteToken}`);

const vaultPubkey = await solVaultPubkey(
args.bridgeProgram,
args.remoteToken
);
const vaultPubkey = await solVaultPubkey(args.bridgeProgram);

logger.success(`SOL Vault PDA: ${vaultPubkey}`);
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
monitorMessageExecution,
buildPayForRelayInstruction,
outgoingMessagePubkey,
solVaultPubkey,
} from "@internal/sol";
import { CONFIGS, DEPLOY_ENVS } from "@internal/constants";

Expand Down Expand Up @@ -71,10 +72,7 @@ export async function handleBridgeSol(args: Args): Promise<void> {

const bridge = await fetchBridge(rpc, bridgeAccountAddress);

const [solVaultAddress] = await getProgramDerivedAddress({
programAddress: config.solana.bridgeProgram,
seeds: [Buffer.from(getIdlConstant("SOL_VAULT_SEED"))],
});
const solVaultAddress = await solVaultPubkey(config.solana.bridgeProgram);
logger.info(`Sol Vault: ${solVaultAddress}`);

// Calculate scaled amount (amount * 10^decimals)
Expand Down
8 changes: 4 additions & 4 deletions scripts/src/internal/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ export const CONFIGS = {
evmKeychainKey: "0xfc85de3f52047b993b2dda967b606a8b9caa2c29",

// Programs
bridgeProgram: address("GaxAZQ3BSYjfG65e8mGnBnNpmhqRHDJ33aKEASHh3A3P"),
bridgeProgram: address("6YpL1h2a9u6LuNVi55vAes36xNszt2UDm3Zk1kj4WSBm"),
baseRelayerProgram: address(
"HPLodLSVpcUX73cXxT7NNss1frnr2XWf6yK3KPChRTjJ"
"ETsFnoWdJK8N7VJW6XXjiciyB2xeQfCXMQWNa85Zi9cn"
),

// SPLs
Expand All @@ -75,12 +75,12 @@ export const CONFIGS = {
chain: baseSepolia,

// Contracts
bridgeContract: "0x9810d475E698aEc2E65B4941343A0eF76692CCaD",
bridgeContract: "0x64567a9147fa89B1edc987e36Eb6f4b6db71656b",
counterContract: "0x5d3eB988Daa06151b68369cf957e917B4371d35d",

// ERC20s
erc20: "0x62C1332822983B8412A6Ffda0fd77cd7d5733Ee9",
wSol: "0xb0d5170e1962a40Ed2F04B86193698f85770A706",
wSol: "0x003512146Fd54b71f926C7Fd4B7bd20Fc84E22c5",
wSpl: "0x80351342c4dd23C78c0837C640E041a239e67cD8",
},
},
Expand Down
13 changes: 2 additions & 11 deletions scripts/src/internal/sol/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
getProgramDerivedAddress,
type Address as SolanaAddress,
} from "@solana/kit";
import { toBytes, type Address as EvmAddress } from "viem";

import { getIdlConstant } from "./bridge-idl.constants";

Expand All @@ -24,18 +23,10 @@ export async function outgoingMessagePubkey(
return { salt: s, pubkey };
}

export async function solVaultPubkey(
bridgeProgram: SolanaAddress,
remoteToken: EvmAddress
) {
const remoteTokenBytes = toBytes(remoteToken);

export async function solVaultPubkey(bridgeProgram: SolanaAddress) {
const [pubkey] = await getProgramDerivedAddress({
programAddress: bridgeProgram,
seeds: [
Buffer.from(getIdlConstant("SOL_VAULT_SEED")),
Buffer.from(remoteTokenBytes),
],
seeds: [Buffer.from(getIdlConstant("SOL_VAULT_SEED"))],
});

return pubkey;
Expand Down
4 changes: 3 additions & 1 deletion scripts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
// Path mapping
"baseUrl": ".",
"paths": {
"@internal/*": ["src/internal/*"]
"@internal/*": ["src/internal/*"],
"@base/bridge": ["../clients/ts/src/index.ts"],
"@base/bridge/*": ["../clients/ts/src/*"]
}
}
}
Loading