Skip to content

Commit b0d5380

Browse files
⬆️ Upgrade ephemeral rollups sdk (#121)
1 parent 0bca0f4 commit b0d5380

File tree

13 files changed

+196
-249
lines changed

13 files changed

+196
-249
lines changed

Cargo.lock

Lines changed: 118 additions & 70 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ anyhow = "1.0.32"
5656
heck = "0.5.0"
5757
clap = { version = "4.2.4", features = ["derive"] }
5858
ahash = "=0.8.11"
59-
ephemeral-rollups-sdk = "=0.0.6"
59+
ephemeral-rollups-sdk = "=0.2.1"
6060

6161
[profile.release]
6262
overflow-checks = true

clients/bolt-sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"license": "MIT",
77
"private": false,
88
"dependencies": {
9-
"@magicblock-labs/ephemeral-rollups-sdk": "0.0.6",
9+
"@magicblock-labs/ephemeral-rollups-sdk": "0.2.1",
1010
"@metaplex-foundation/beet": "^0.7.1",
1111
"@metaplex-foundation/beet-solana": "^0.4.0",
1212
"@coral-xyz/anchor": "^0.30.1"

clients/bolt-sdk/src/delegation/allow_undelegation.ts

Lines changed: 0 additions & 75 deletions
This file was deleted.

clients/bolt-sdk/src/delegation/delegate.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import * as beet from "@metaplex-foundation/beet";
2+
import * as beetSolana from "@metaplex-foundation/beet-solana";
23
import * as web3 from "@solana/web3.js";
34
import {
4-
DelegateAccounts,
5+
delegateBufferPdaFromDelegatedAccountAndOwnerProgram,
56
DELEGATION_PROGRAM_ID,
7+
delegationMetadataPdaFromDelegatedAccount,
8+
delegationRecordPdaFromDelegatedAccount,
69
} from "@magicblock-labs/ephemeral-rollups-sdk";
710
import { FindComponentPda } from "../index";
811
import {
@@ -12,8 +15,8 @@ import {
1215
} from "@solana/web3.js";
1316

1417
export interface DelegateInstructionArgs {
15-
validUntil: beet.bignum;
1618
commitFrequencyMs: number;
19+
validator: beet.COption<PublicKey>;
1720
}
1821

1922
export const delegateStruct = new beet.FixableBeetArgsStruct<
@@ -23,8 +26,8 @@ export const delegateStruct = new beet.FixableBeetArgsStruct<
2326
>(
2427
[
2528
["instructionDiscriminator", beet.uniformFixedSizeArray(beet.u8, 8)],
26-
["validUntil", beet.i64],
2729
["commitFrequencyMs", beet.u32],
30+
["validator", beet.coption(beetSolana.publicKey)],
2831
],
2932
"DelegateInstructionArgs",
3033
);
@@ -56,17 +59,25 @@ export const delegateInstructionDiscriminator = [
5659

5760
export function createDelegateInstruction(
5861
accounts: DelegateInstructionAccounts,
59-
validUntil: beet.bignum = 0,
60-
commitFrequencyMs: number = 30000,
62+
commitFrequencyMs: number = 0,
63+
validator?: PublicKey,
6164
programId = accounts.ownerProgram,
6265
) {
6366
const [data] = delegateStruct.serialize({
6467
instructionDiscriminator: delegateInstructionDiscriminator,
65-
validUntil,
6668
commitFrequencyMs,
69+
validator: validator ?? null,
6770
});
6871

69-
const { delegationPda, delegationMetadata, bufferPda } = DelegateAccounts(
72+
const delegationRecord = delegationRecordPdaFromDelegatedAccount(
73+
accounts.account,
74+
);
75+
76+
const delegationMetadata = delegationMetadataPdaFromDelegatedAccount(
77+
accounts.account,
78+
);
79+
80+
const bufferPda = delegateBufferPdaFromDelegatedAccountAndOwnerProgram(
7081
accounts.account,
7182
accounts.ownerProgram,
7283
);
@@ -98,7 +109,7 @@ export function createDelegateInstruction(
98109
isSigner: false,
99110
},
100111
{
101-
pubkey: accounts.delegationRecord ?? delegationPda,
112+
pubkey: accounts.delegationRecord ?? delegationRecord,
102113
isWritable: true,
103114
isSigner: false,
104115
},

clients/bolt-sdk/src/generated/idl/world.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"address": "WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n",
33
"metadata": {
44
"name": "world",
5-
"version": "0.1.10",
5+
"version": "0.1.12",
66
"spec": "0.1.0",
77
"description": "Bolt World program",
88
"repository": "https://github.com/magicblock-labs/bolt"

clients/bolt-sdk/src/generated/types/world.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export type World = {
88
address: "WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n";
99
metadata: {
1010
name: "world";
11-
version: "0.1.10";
11+
version: "0.1.12";
1212
spec: "0.1.0";
1313
description: "Bolt World program";
1414
repository: "https://github.com/magicblock-labs/bolt";

clients/bolt-sdk/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export * from "./generated/instructions";
66
export * from "./world/transactions";
77
export * from "./delegation/delegate";
88
export * from "./delegation/undelegate";
9-
export * from "./delegation/allow_undelegation";
109
export { DELEGATION_PROGRAM_ID } from "@magicblock-labs/ephemeral-rollups-sdk";
1110

1211
// Re-export anchor

clients/bolt-sdk/yarn.lock

Lines changed: 21 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@
99
dependencies:
1010
regenerator-runtime "^0.14.0"
1111

12-
"@babel/runtime@^7.24.7":
13-
version "7.24.7"
14-
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.24.7.tgz#f4f0d5530e8dbdf59b3451b9b3e594b6ba082e12"
15-
integrity sha512-UwgBRMjJP+xv857DCngvqXI3Iq6J4v0wXmwc6sapg+zyhbwmQX67LUEFrkK5tbyJ30jGuG3ZvWpBiB9LCy1kWw==
16-
dependencies:
17-
regenerator-runtime "^0.14.0"
18-
1912
"@babel/runtime@^7.25.0":
2013
version "7.25.7"
2114
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.25.7.tgz#7ffb53c37a8f247c8c4d335e89cdf16a2e0d0fb6"
@@ -69,13 +62,14 @@
6962
wrap-ansi "^8.1.0"
7063
wrap-ansi-cjs "npm:wrap-ansi@^7.0.0"
7164

72-
"@magicblock-labs/ephemeral-rollups-sdk@0.0.6":
73-
version "0.0.6"
74-
resolved "https://registry.yarnpkg.com/@magicblock-labs/ephemeral-rollups-sdk/-/ephemeral-rollups-sdk-0.0.6.tgz#47a667d9fd7df76752660a6d82688e54174241ab"
75-
integrity sha512-moep9ja4fmDXPa0OcjJBvvOTUNrds8rwTzxmbGd5Myu/6AsykcCpTuUZjleQCRotu/yODLVkpheMDr1S0/mtpA==
65+
"@magicblock-labs/ephemeral-rollups-sdk@0.2.1":
66+
version "0.2.1"
67+
resolved "https://registry.yarnpkg.com/@magicblock-labs/ephemeral-rollups-sdk/-/ephemeral-rollups-sdk-0.2.1.tgz#bf85a0725b9fe47bc96738a99bf9e84aa9e405d0"
68+
integrity sha512-s1j6kXLbg6hA5ysSkG1pGEutAdxPOymtl2I94pD5UVfWWILcR0rbqONOvNV1WKDGZbILqC1AjFl/7GJGRMKB5Q==
7669
dependencies:
7770
"@metaplex-foundation/beet" "^0.7.2"
78-
"@solana/web3.js" "^1.92.3"
71+
"@solana/web3.js" "^1.98.0"
72+
rpc-websockets "^9.0.4"
7973

8074
"@metaplex-foundation/beet-solana@^0.3.1":
8175
version "0.3.1"
@@ -150,13 +144,6 @@
150144
dependencies:
151145
"@noble/hashes" "1.3.3"
152146

153-
"@noble/curves@^1.4.0":
154-
version "1.4.0"
155-
resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.4.0.tgz#f05771ef64da724997f69ee1261b2417a49522d6"
156-
integrity sha512-p+4cb332SFCrReJkCYe8Xzm0OWi4Jji5jVdIZRL/PmacmDkFNw6MrrV+gGpiPxLHbV+zKFRywUWbaseT+tZRXg==
157-
dependencies:
158-
"@noble/hashes" "1.4.0"
159-
160147
"@noble/curves@^1.4.2":
161148
version "1.6.0"
162149
resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.6.0.tgz#be5296ebcd5a1730fccea4786d420f87abfeb40b"
@@ -169,16 +156,16 @@
169156
resolved "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.3.tgz"
170157
integrity sha512-V7/fPHgl+jsVPXqqeOzT8egNj2iBIVt+ECeMMG8TdcnTikP3oaBtUVqpT/gYCR68aEBJSF+XbYUxStjbFMqIIA==
171158

172-
"@noble/[email protected]", "@noble/hashes@^1.4.0":
173-
version "1.4.0"
174-
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.4.0.tgz#45814aa329f30e4fe0ba49426f49dfccdd066426"
175-
integrity sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==
176-
177159
178160
version "1.5.0"
179161
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.5.0.tgz#abadc5ca20332db2b1b2aa3e496e9af1213570b0"
180162
integrity sha512-1j6kQFb7QRru7eKN3ZDvRcP13rugwdxZqCjbiAVZfIJwgj2A65UmT4TgARXGlXgnRkORLTDTrO19ZErt7+QXgA==
181163

164+
"@noble/hashes@^1.4.0":
165+
version "1.4.0"
166+
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.4.0.tgz#45814aa329f30e4fe0ba49426f49dfccdd066426"
167+
integrity sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==
168+
182169
"@pkgjs/parseargs@^0.11.0":
183170
version "0.11.0"
184171
resolved "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz"
@@ -233,13 +220,13 @@
233220
rpc-websockets "^9.0.2"
234221
superstruct "^2.0.2"
235222

236-
"@solana/web3.js@^1.92.3":
237-
version "1.93.0"
238-
resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.93.0.tgz#4b6975020993cec2f6626e4f2bf559ca042df8db"
239-
integrity sha512-suf4VYwWxERz4tKoPpXCRHFRNst7jmcFUaD65kII+zg9urpy5PeeqgLV6G5eWGzcVzA9tZeXOju1A1Y+0ojEVw==
223+
"@solana/web3.js@^1.98.0":
224+
version "1.98.0"
225+
resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.98.0.tgz#21ecfe8198c10831df6f0cfde7f68370d0405917"
226+
integrity sha512-nz3Q5OeyGFpFCR+erX2f6JPt3sKhzhYcSycBCSPkWjzSVDh/Rr1FqTVMRe58FKO16/ivTUcuJjeS5MyBvpkbzA==
240227
dependencies:
241-
"@babel/runtime" "^7.24.7"
242-
"@noble/curves" "^1.4.0"
228+
"@babel/runtime" "^7.25.0"
229+
"@noble/curves" "^1.4.2"
243230
"@noble/hashes" "^1.4.0"
244231
"@solana/buffer-layout" "^4.0.1"
245232
agentkeepalive "^4.5.0"
@@ -249,10 +236,10 @@
249236
bs58 "^4.0.1"
250237
buffer "6.0.3"
251238
fast-stable-stringify "^1.0.0"
252-
jayson "^4.1.0"
239+
jayson "^4.1.1"
253240
node-fetch "^2.7.0"
254-
rpc-websockets "^9.0.0"
255-
superstruct "^1.0.4"
241+
rpc-websockets "^9.0.2"
242+
superstruct "^2.0.2"
256243

257244
"@swc/helpers@^0.5.11":
258245
version "0.5.11"
@@ -1071,23 +1058,7 @@ rpc-websockets@^7.5.1:
10711058
bufferutil "^4.0.1"
10721059
utf-8-validate "^5.0.2"
10731060

1074-
rpc-websockets@^9.0.0:
1075-
version "9.0.2"
1076-
resolved "https://registry.yarnpkg.com/rpc-websockets/-/rpc-websockets-9.0.2.tgz#4c1568d00b8100f997379a363478f41f8f4b242c"
1077-
integrity sha512-YzggvfItxMY3Lwuax5rC18inhbjJv9Py7JXRHxTIi94JOLrqBsSsUUc5bbl5W6c11tXhdfpDPK0KzBhoGe8jjw==
1078-
dependencies:
1079-
"@swc/helpers" "^0.5.11"
1080-
"@types/uuid" "^8.3.4"
1081-
"@types/ws" "^8.2.2"
1082-
buffer "^6.0.3"
1083-
eventemitter3 "^5.0.1"
1084-
uuid "^8.3.2"
1085-
ws "^8.5.0"
1086-
optionalDependencies:
1087-
bufferutil "^4.0.1"
1088-
utf-8-validate "^5.0.2"
1089-
1090-
rpc-websockets@^9.0.2:
1061+
rpc-websockets@^9.0.2, rpc-websockets@^9.0.4:
10911062
version "9.0.4"
10921063
resolved "https://registry.yarnpkg.com/rpc-websockets/-/rpc-websockets-9.0.4.tgz#9d8ee82533b5d1e13d9ded729e3e38d0d8fa083f"
10931064
integrity sha512-yWZWN0M+bivtoNLnaDbtny4XchdAIF5Q4g/ZsC5UC61Ckbp0QczwO8fg44rV3uYmY4WHd+EZQbn90W1d8ojzqQ==
@@ -1243,11 +1214,6 @@ superstruct@^0.15.4:
12431214
resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-0.15.5.tgz#0f0a8d3ce31313f0d84c6096cd4fa1bfdedc9dab"
12441215
integrity sha512-4AOeU+P5UuE/4nOUkmcQdW5y7i9ndt1cQd/3iUe+LTz3RxESf/W/5lg4B74HbDMMv8PHnPnGCQFH45kBcrQYoQ==
12451216

1246-
superstruct@^1.0.4:
1247-
version "1.0.4"
1248-
resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-1.0.4.tgz#0adb99a7578bd2f1c526220da6571b2d485d91ca"
1249-
integrity sha512-7JpaAoX2NGyoFlI9NBh66BQXGONc+uE+MRS5i2iOBKuS4e+ccgMDjATgZldkah+33DakBxDHiss9kvUcGAO8UQ==
1250-
12511217
superstruct@^2.0.2:
12521218
version "2.0.2"
12531219
resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-2.0.2.tgz#3f6d32fbdc11c357deff127d591a39b996300c54"

crates/bolt-lang/attribute/delegate/src/lib.rs

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -137,35 +137,31 @@ fn generate_delegate(component_type: &Type) -> (TokenStream2, TokenStream2) {
137137
(
138138
quote! {
139139
#[automatically_derived]
140-
pub fn delegate(ctx: Context<DelegateInput>, valid_until: i64, commit_frequency_ms: u32) -> Result<()> {
140+
pub fn delegate(ctx: Context<DelegateInput>, commit_frequency_ms: u32, validator: Option<Pubkey>) -> Result<()> {
141+
let pda_seeds: &[&[u8]] = &[<#component_type>::seed(), &ctx.accounts.entity.key().to_bytes()];
141142

142-
let [payer, entity, account, owner_program, buffer, delegation_record, delegate_account_seeds, delegation_program, system_program] = [
143-
&ctx.accounts.payer,
144-
&ctx.accounts.entity.to_account_info(),
145-
&ctx.accounts.account,
146-
&ctx.accounts.owner_program,
147-
&ctx.accounts.buffer,
148-
&ctx.accounts.delegation_record,
149-
&ctx.accounts.delegate_account_seeds,
150-
&ctx.accounts.delegation_program,
151-
&ctx.accounts.system_program,
152-
];
143+
let del_accounts = ::bolt_lang::DelegateAccounts {
144+
payer: &ctx.accounts.payer,
145+
pda: &ctx.accounts.account,
146+
owner_program: &ctx.accounts.owner_program,
147+
buffer: &ctx.accounts.buffer,
148+
delegation_record: &ctx.accounts.delegation_record,
149+
delegation_metadata: &ctx.accounts.delegation_metadata,
150+
delegation_program: &ctx.accounts.delegation_program,
151+
system_program: &ctx.accounts.system_program,
152+
};
153153

154-
let pda_seeds: &[&[u8]] = &[<#component_type>::seed(), &entity.key.to_bytes()];
154+
let config = ::bolt_lang::DelegateConfig {
155+
commit_frequency_ms,
156+
validator,
157+
};
155158

156159
::bolt_lang::delegate_account(
157-
payer,
158-
account,
159-
owner_program,
160-
buffer,
161-
delegation_record,
162-
delegate_account_seeds,
163-
delegation_program,
164-
system_program,
160+
del_accounts,
165161
pda_seeds,
166-
valid_until,
167-
commit_frequency_ms,
162+
config,
168163
)?;
164+
169165
Ok(())
170166
}
171167
},
@@ -189,7 +185,7 @@ fn generate_delegate(component_type: &Type) -> (TokenStream2, TokenStream2) {
189185
pub delegation_record: AccountInfo<'info>,
190186
/// CHECK:`
191187
#[account(mut)]
192-
pub delegate_account_seeds: AccountInfo<'info>,
188+
pub delegation_metadata: AccountInfo<'info>,
193189
/// CHECK:`
194190
pub delegation_program: AccountInfo<'info>,
195191
/// CHECK:`

0 commit comments

Comments
 (0)