Skip to content

Commit e9b5fe2

Browse files
authored
chore(clients): regenerate clients and fix scripts (#157)
* chore(clients): regenerate clients and fix scripts * fix(scripts): remove remote sol from PDA seed
1 parent e6c5f24 commit e9b5fe2

13 files changed

Lines changed: 94 additions & 130 deletions

File tree

clients/ts/src/bridge/generated/accounts/bridge.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,5 +213,5 @@ export async function fetchAllMaybeBridge(
213213
}
214214

215215
export function getBridgeSize(): number {
216-
return 508;
216+
return 528;
217217
}

clients/ts/src/bridge/generated/errors/bridge.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ export const BRIDGE_ERROR__INVALID_GAS_COST_SCALER_DP = 0x3206; // 12806
102102
export const BRIDGE_ERROR__INVALID_BLOCK_INTERVAL_REQUIREMENT = 0x3207; // 12807
103103
/** CreationWithNonZeroTarget: Creation with non-zero target */
104104
export const BRIDGE_ERROR__CREATION_WITH_NON_ZERO_TARGET = 0x3264; // 12900
105+
/** ZeroAddress: Zero address */
106+
export const BRIDGE_ERROR__ZERO_ADDRESS = 0x3265; // 12901
105107

106108
export type BridgeError =
107109
| typeof BRIDGE_ERROR__ALREADY_EXECUTED
@@ -147,7 +149,8 @@ export type BridgeError =
147149
| typeof BRIDGE_ERROR__TOO_MANY_SIGNERS
148150
| typeof BRIDGE_ERROR__UNAUTHORIZED_CONFIG_UPDATE
149151
| typeof BRIDGE_ERROR__UNAUTHORIZED_INITIALIZATION
150-
| typeof BRIDGE_ERROR__UNUSED_PROOF_ELEMENTS_REMAINING;
152+
| typeof BRIDGE_ERROR__UNUSED_PROOF_ELEMENTS_REMAINING
153+
| typeof BRIDGE_ERROR__ZERO_ADDRESS;
151154

152155
let bridgeErrorMessages: Record<BridgeError, string> | undefined;
153156
if (process.env.NODE_ENV !== 'production') {
@@ -196,6 +199,7 @@ if (process.env.NODE_ENV !== 'production') {
196199
[BRIDGE_ERROR__UNAUTHORIZED_CONFIG_UPDATE]: `Unauthorized to update configuration`,
197200
[BRIDGE_ERROR__UNAUTHORIZED_INITIALIZATION]: `Only the upgrade authority can initialize the bridge`,
198201
[BRIDGE_ERROR__UNUSED_PROOF_ELEMENTS_REMAINING]: `Unused proof elements remaining`,
202+
[BRIDGE_ERROR__ZERO_ADDRESS]: `Zero address`,
199203
};
200204
}
201205

clients/ts/src/bridge/generated/instructions/bridgeCall.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export type BridgeCallInput<
155155
bridge: Address<TAccountBridge>;
156156
/**
157157
* The outgoing message account that stores the cross-chain call data.
158-
* - Created fresh for each bridge call at a client-provided address (not a PDA)
158+
* - Created fresh for each bridge call seeded by a client-provided salt
159159
* - Payer funds the account creation
160160
* - Space is DISCRIMINATOR_LEN + OutgoingMessage::space(...)` and is sized using
161161
* the worst-case message variant to ensure sufficient capacity even for large payloads
@@ -276,7 +276,7 @@ export type ParsedBridgeCallInstruction<
276276
bridge: TAccountMetas[3];
277277
/**
278278
* The outgoing message account that stores the cross-chain call data.
279-
* - Created fresh for each bridge call at a client-provided address (not a PDA)
279+
* - Created fresh for each bridge call seeded by a client-provided salt
280280
* - Payer funds the account creation
281281
* - Space is DISCRIMINATOR_LEN + OutgoingMessage::space(...)` and is sized using
282282
* the worst-case message variant to ensure sufficient capacity even for large payloads

clients/ts/src/bridge/generated/instructions/bridgeSol.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,13 @@ export type BridgeSolInstructionData = {
9999
discriminator: ReadonlyUint8Array;
100100
outgoingMessageSalt: ReadonlyUint8Array;
101101
to: ReadonlyUint8Array;
102-
remoteToken: ReadonlyUint8Array;
103102
amount: bigint;
104103
call: Option<Call>;
105104
};
106105

107106
export type BridgeSolInstructionDataArgs = {
108107
outgoingMessageSalt: ReadonlyUint8Array;
109108
to: ReadonlyUint8Array;
110-
remoteToken: ReadonlyUint8Array;
111109
amount: number | bigint;
112110
call: OptionOrNullable<CallArgs>;
113111
};
@@ -118,7 +116,6 @@ export function getBridgeSolInstructionDataEncoder(): Encoder<BridgeSolInstructi
118116
['discriminator', fixEncoderSize(getBytesEncoder(), 8)],
119117
['outgoingMessageSalt', fixEncoderSize(getBytesEncoder(), 32)],
120118
['to', fixEncoderSize(getBytesEncoder(), 20)],
121-
['remoteToken', fixEncoderSize(getBytesEncoder(), 20)],
122119
['amount', getU64Encoder()],
123120
['call', getOptionEncoder(getCallEncoder())],
124121
]),
@@ -131,7 +128,6 @@ export function getBridgeSolInstructionDataDecoder(): Decoder<BridgeSolInstructi
131128
['discriminator', fixDecoderSize(getBytesDecoder(), 8)],
132129
['outgoingMessageSalt', fixDecoderSize(getBytesDecoder(), 32)],
133130
['to', fixDecoderSize(getBytesDecoder(), 20)],
134-
['remoteToken', fixDecoderSize(getBytesDecoder(), 20)],
135131
['amount', getU64Decoder()],
136132
['call', getOptionDecoder(getCallDecoder())],
137133
]);
@@ -170,7 +166,7 @@ export type BridgeSolInput<
170166
gasFeeReceiver: Address<TAccountGasFeeReceiver>;
171167
/**
172168
* The SOL vault account that holds locked tokens for the specific remote token.
173-
* - Uses PDA with SOL_VAULT_SEED and remote_token for deterministic address
169+
* - Uses PDA with SOL_VAULT_SEED for deterministic address
174170
* - Mutable to receive the locked SOL tokens
175171
* - Each remote token has its own dedicated vault
176172
*
@@ -196,7 +192,6 @@ export type BridgeSolInput<
196192
systemProgram?: Address<TAccountSystemProgram>;
197193
outgoingMessageSalt: BridgeSolInstructionDataArgs['outgoingMessageSalt'];
198194
to: BridgeSolInstructionDataArgs['to'];
199-
remoteToken: BridgeSolInstructionDataArgs['remoteToken'];
200195
amount: BridgeSolInstructionDataArgs['amount'];
201196
call: BridgeSolInstructionDataArgs['call'];
202197
};
@@ -305,7 +300,7 @@ export type ParsedBridgeSolInstruction<
305300
gasFeeReceiver: TAccountMetas[2];
306301
/**
307302
* The SOL vault account that holds locked tokens for the specific remote token.
308-
* - Uses PDA with SOL_VAULT_SEED and remote_token for deterministic address
303+
* - Uses PDA with SOL_VAULT_SEED for deterministic address
309304
* - Mutable to receive the locked SOL tokens
310305
* - Each remote token has its own dedicated vault
311306
*

clients/ts/src/bridge/generated/instructions/bridgeSolWithBufferedCall.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,12 @@ export type BridgeSolWithBufferedCallInstructionData = {
100100
discriminator: ReadonlyUint8Array;
101101
outgoingMessageSalt: ReadonlyUint8Array;
102102
to: ReadonlyUint8Array;
103-
remoteToken: ReadonlyUint8Array;
104103
amount: bigint;
105104
};
106105

107106
export type BridgeSolWithBufferedCallInstructionDataArgs = {
108107
outgoingMessageSalt: ReadonlyUint8Array;
109108
to: ReadonlyUint8Array;
110-
remoteToken: ReadonlyUint8Array;
111109
amount: number | bigint;
112110
};
113111

@@ -117,7 +115,6 @@ export function getBridgeSolWithBufferedCallInstructionDataEncoder(): FixedSizeE
117115
['discriminator', fixEncoderSize(getBytesEncoder(), 8)],
118116
['outgoingMessageSalt', fixEncoderSize(getBytesEncoder(), 32)],
119117
['to', fixEncoderSize(getBytesEncoder(), 20)],
120-
['remoteToken', fixEncoderSize(getBytesEncoder(), 20)],
121118
['amount', getU64Encoder()],
122119
]),
123120
(value) => ({
@@ -132,7 +129,6 @@ export function getBridgeSolWithBufferedCallInstructionDataDecoder(): FixedSizeD
132129
['discriminator', fixDecoderSize(getBytesDecoder(), 8)],
133130
['outgoingMessageSalt', fixDecoderSize(getBytesDecoder(), 32)],
134131
['to', fixDecoderSize(getBytesDecoder(), 20)],
135-
['remoteToken', fixDecoderSize(getBytesDecoder(), 20)],
136132
['amount', getU64Decoder()],
137133
]);
138134
}
@@ -172,7 +168,7 @@ export type BridgeSolWithBufferedCallInput<
172168
gasFeeReceiver: Address<TAccountGasFeeReceiver>;
173169
/**
174170
* The SOL vault account that holds locked tokens for the specific remote token.
175-
* - PDA of this program using `[SOL_VAULT_SEED, remote_token]`
171+
* - PDA of this program using `[SOL_VAULT_SEED]`
176172
* - Mutable to receive the locked SOL
177173
* - Each remote token has its own dedicated vault
178174
*
@@ -203,7 +199,6 @@ export type BridgeSolWithBufferedCallInput<
203199
systemProgram?: Address<TAccountSystemProgram>;
204200
outgoingMessageSalt: BridgeSolWithBufferedCallInstructionDataArgs['outgoingMessageSalt'];
205201
to: BridgeSolWithBufferedCallInstructionDataArgs['to'];
206-
remoteToken: BridgeSolWithBufferedCallInstructionDataArgs['remoteToken'];
207202
amount: BridgeSolWithBufferedCallInstructionDataArgs['amount'];
208203
};
209204

@@ -323,7 +318,7 @@ export type ParsedBridgeSolWithBufferedCallInstruction<
323318
gasFeeReceiver: TAccountMetas[2];
324319
/**
325320
* The SOL vault account that holds locked tokens for the specific remote token.
326-
* - PDA of this program using `[SOL_VAULT_SEED, remote_token]`
321+
* - PDA of this program using `[SOL_VAULT_SEED]`
327322
* - Mutable to receive the locked SOL
328323
* - Each remote token has its own dedicated vault
329324
*

clients/ts/src/bridge/generated/types/finalizeBridgeSol.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,8 @@
88

99
import {
1010
combineCodec,
11-
fixDecoderSize,
12-
fixEncoderSize,
1311
getAddressDecoder,
1412
getAddressEncoder,
15-
getBytesDecoder,
16-
getBytesEncoder,
1713
getStructDecoder,
1814
getStructEncoder,
1915
getU64Decoder,
@@ -22,7 +18,6 @@ import {
2218
type FixedSizeCodec,
2319
type FixedSizeDecoder,
2420
type FixedSizeEncoder,
25-
type ReadonlyUint8Array,
2621
} from '@solana/kit';
2722

2823
/**
@@ -33,12 +28,6 @@ import {
3328
* the recipient when finalized.
3429
*/
3530
export type FinalizeBridgeSol = {
36-
/**
37-
* The 20-byte EVM address on Base of the ERC-20 token that represents SOL for this bridge.
38-
* Used as a seed to derive the SOL vault PDA that escrows SOL for this mapping.
39-
* This identifier names the vault even though the asset released here is native SOL.
40-
*/
41-
remoteToken: ReadonlyUint8Array;
4231
/**
4332
* The Solana public key of the recipient who will receive the SOL.
4433
* This must match the intended recipient specified in the original bridge message.
@@ -52,12 +41,6 @@ export type FinalizeBridgeSol = {
5241
};
5342

5443
export type FinalizeBridgeSolArgs = {
55-
/**
56-
* The 20-byte EVM address on Base of the ERC-20 token that represents SOL for this bridge.
57-
* Used as a seed to derive the SOL vault PDA that escrows SOL for this mapping.
58-
* This identifier names the vault even though the asset released here is native SOL.
59-
*/
60-
remoteToken: ReadonlyUint8Array;
6144
/**
6245
* The Solana public key of the recipient who will receive the SOL.
6346
* This must match the intended recipient specified in the original bridge message.
@@ -72,15 +55,13 @@ export type FinalizeBridgeSolArgs = {
7255

7356
export function getFinalizeBridgeSolEncoder(): FixedSizeEncoder<FinalizeBridgeSolArgs> {
7457
return getStructEncoder([
75-
['remoteToken', fixEncoderSize(getBytesEncoder(), 20)],
7658
['to', getAddressEncoder()],
7759
['amount', getU64Encoder()],
7860
]);
7961
}
8062

8163
export function getFinalizeBridgeSolDecoder(): FixedSizeDecoder<FinalizeBridgeSol> {
8264
return getStructDecoder([
83-
['remoteToken', fixDecoderSize(getBytesDecoder(), 20)],
8465
['to', getAddressDecoder()],
8566
['amount', getU64Decoder()],
8667
]);

clients/ts/src/bridge/generated/types/protocolConfig.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,18 @@
88

99
import {
1010
combineCodec,
11+
fixDecoderSize,
12+
fixEncoderSize,
13+
getBytesDecoder,
14+
getBytesEncoder,
1115
getStructDecoder,
1216
getStructEncoder,
1317
getU64Decoder,
1418
getU64Encoder,
1519
type FixedSizeCodec,
1620
type FixedSizeDecoder,
1721
type FixedSizeEncoder,
22+
type ReadonlyUint8Array,
1823
} from '@solana/kit';
1924

2025
export type ProtocolConfig = {
@@ -23,6 +28,8 @@ export type ProtocolConfig = {
2328
* submitted output root must be a multiple of this number.
2429
*/
2530
blockIntervalRequirement: bigint;
31+
/** The Base evm address of SOL */
32+
remoteSolAddress: ReadonlyUint8Array;
2633
};
2734

2835
export type ProtocolConfigArgs = {
@@ -31,14 +38,22 @@ export type ProtocolConfigArgs = {
3138
* submitted output root must be a multiple of this number.
3239
*/
3340
blockIntervalRequirement: number | bigint;
41+
/** The Base evm address of SOL */
42+
remoteSolAddress: ReadonlyUint8Array;
3443
};
3544

3645
export function getProtocolConfigEncoder(): FixedSizeEncoder<ProtocolConfigArgs> {
37-
return getStructEncoder([['blockIntervalRequirement', getU64Encoder()]]);
46+
return getStructEncoder([
47+
['blockIntervalRequirement', getU64Encoder()],
48+
['remoteSolAddress', fixEncoderSize(getBytesEncoder(), 20)],
49+
]);
3850
}
3951

4052
export function getProtocolConfigDecoder(): FixedSizeDecoder<ProtocolConfig> {
41-
return getStructDecoder([['blockIntervalRequirement', getU64Decoder()]]);
53+
return getStructDecoder([
54+
['blockIntervalRequirement', getU64Decoder()],
55+
['remoteSolAddress', fixDecoderSize(getBytesDecoder(), 20)],
56+
]);
4257
}
4358

4459
export function getProtocolConfigCodec(): FixedSizeCodec<

scripts/src/commands/sol/bridge/base-to-solana/relay-message.handler.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { TOKEN_2022_PROGRAM_ADDRESS } from "@solana-program/token-2022";
1414
import { toBytes, toHex } from "viem";
1515

1616
import {
17+
fetchBridge,
1718
fetchIncomingMessage,
1819
getRelayMessageInstruction,
1920
type BridgeBaseToSolanaStateIncomingMessageMessage,
@@ -254,19 +255,15 @@ async function messageTransferSolAccounts(
254255
) {
255256
logger.info("SOL transfer detected");
256257

257-
const { remoteToken, to, amount } = message.fields[0];
258+
const { to, amount } = message.fields[0];
258259

259260
logger.info(`SOL transfer:`);
260-
logger.info(` Remote token: 0x${remoteToken.toHex()}`);
261261
logger.info(` To: ${to}`);
262262
logger.info(` Amount: ${amount}`);
263263

264264
const [solVaultPda] = await getProgramDerivedAddress({
265265
programAddress: solanaBridge,
266-
seeds: [
267-
Buffer.from(getIdlConstant("SOL_VAULT_SEED")),
268-
Buffer.from(remoteToken),
269-
],
266+
seeds: [Buffer.from(getIdlConstant("SOL_VAULT_SEED"))],
270267
});
271268
logger.info(`SOL vault PDA: ${solVaultPda}`);
272269

scripts/src/commands/sol/bridge/initialize.command.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { text, isCancel, cancel } from "@clack/prompts";
44
import {
55
getOrPromptBigint,
66
getOrPromptSolanaAddress,
7+
getOrPromptEvmAddress,
78
getOrPromptEvmAddressList,
89
getOrPromptFilePath,
910
validateAndExecute,
@@ -15,6 +16,7 @@ type CommanderOptions = {
1516
rpcUrl?: string;
1617
payerKp?: string;
1718
guardian?: string;
19+
remoteSolAddress?: string;
1820
eip1559Target?: string;
1921
eip1559Denominator?: string;
2022
eip1559WindowDurationSeconds?: string;
@@ -77,6 +79,11 @@ async function collectInteractiveOptions(
7779
["payer"]
7880
);
7981

82+
opts.remoteSolAddress = await getOrPromptEvmAddress(
83+
opts.remoteSolAddress,
84+
"Enter remote SOL address (EVM address)"
85+
);
86+
8087
opts.eip1559Target = await getOrPromptBigint(
8188
opts.eip1559Target,
8289
"Enter EIP-1559 target (bigint)"
@@ -157,6 +164,10 @@ export const initializeCommand = new Command("initialize")
157164
"--guardian <address>",
158165
"Guardian address: 'payer' or Solana public key"
159166
)
167+
.option(
168+
"--remote-sol-address <address>",
169+
"Remote SOL address (EVM address)"
170+
)
160171
.option("--eip1559-target <uint>", "EIP-1559 target (bigint)")
161172
.option("--eip1559-denominator <uint>", "EIP-1559 denominator (bigint)")
162173
.option(

scripts/src/commands/sol/bridge/initialize.handler.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ const gasFlatSchema = z.object({
6363

6464
const protocolFlatSchema = z.object({
6565
protocolBlockIntervalRequirement: bigintSchema,
66+
remoteSolAddress: evmAddressSchema,
6667
});
6768

6869
const bufferFlatSchema = z.object({
@@ -142,6 +143,7 @@ export async function handleInitialize(args: InitializeArgs): Promise<void> {
142143

143144
const protocolConfig: ProtocolConfig = {
144145
blockIntervalRequirement: args.protocolBlockIntervalRequirement,
146+
remoteSolAddress: toBytes(args.remoteSolAddress),
145147
};
146148

147149
const bufferConfig: BufferConfig = {
@@ -298,6 +300,12 @@ async function assertInitialized(
298300
) {
299301
throw new Error("Protocol config blockIntervalRequirement mismatch!");
300302
}
303+
if (
304+
toHex(new Uint8Array(bridgeData.data.protocolConfig.remoteSolAddress)) !==
305+
toHex(new Uint8Array(protocolConfig.remoteSolAddress))
306+
) {
307+
throw new Error("Protocol config remoteSolAddress mismatch!");
308+
}
301309

302310
// Buffer config confirmation
303311
if (

0 commit comments

Comments
 (0)