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
2 changes: 1 addition & 1 deletion magicblock-er-example/Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ resolution = true
skip-lint = false

[programs.localnet]
er_state_account = "9ChqoFDgVmmvD6Hcajv2JppVZ7S1qPDozrTw4V7q2yLP"
er_state_account = "B39YnkcTaov75XyBCqikwdzjGGkycDU5odMGaGfu57ha"

[registry]
url = "https://api.apr.dev"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl<'info> RandomizeUserStateDelegated<'info> {
..Default::default()
});

self.invoke_signed_vrf(&self.user_account.to_account_info(), &ix)?;
self.invoke_signed_vrf(&self.payer.to_account_info(), &ix)?;

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion magicblock-er-example/programs/er-state-account/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mod instructions;

use instructions::*;

declare_id!("DdDDCwHseMjo4cXkbTPCFA1u5acXmbiEM7w7Dup9iK57");
declare_id!("B39YnkcTaov75XyBCqikwdzjGGkycDU5odMGaGfu57ha");

#[ephemeral]
#[program]
Expand Down
33 changes: 24 additions & 9 deletions magicblock-er-example/tests/er-state-account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import { LAMPORTS_PER_SOL, PublicKey } from "@solana/web3.js";
import { GetCommitmentSignature } from "@magicblock-labs/ephemeral-rollups-sdk";
import { ErStateAccount } from "../target/types/er_state_account";

const DEFAULT_EPHEMERAL_QUEUE = new PublicKey(
"5hBR571xnXppuCPveTrctfTU7tJLSN94nq7kv7FRK5Tc"
);

describe("er-state-account", () => {
// Configure the client to use the local cluster.
const provider = anchor.AnchorProvider.env();
Expand Down Expand Up @@ -95,7 +99,12 @@ describe("er-state-account", () => {
});

it("Update State and Commit to Base Layer!", async () => {
let tx = await program.methods
const ephemeralProgram = new anchor.Program(
program.idl,
providerEphemeralRollup
) as typeof program;

let tx = await ephemeralProgram.methods
.updateCommit(new anchor.BN(43))
.accountsPartial({
user: providerEphemeralRollup.wallet.publicKey,
Expand All @@ -121,11 +130,17 @@ describe("er-state-account", () => {
});

it("Try randomize user state delegated", async () => {
let tx = await program.methods
const ephemeralProgram = new anchor.Program(
program.idl,
providerEphemeralRollup
) as typeof program;

let tx = await ephemeralProgram.methods
.randomizeUserStateDelegated(1)
.accountsPartial({
userAccount: userAccount,
payer: providerEphemeralRollup.wallet.publicKey,
oracleQueue: DEFAULT_EPHEMERAL_QUEUE,
})
.transaction();

Expand All @@ -134,14 +149,14 @@ describe("er-state-account", () => {
tx.recentBlockhash = ( await providerEphemeralRollup.connection.getLatestBlockhash()).blockhash;
tx = await providerEphemeralRollup.wallet.signTransaction(tx);
const txHash = await providerEphemeralRollup.sendAndConfirm(tx, [], { skipPreflight: false });
const txCommitSgn = await GetCommitmentSignature(
txHash,
providerEphemeralRollup.connection,
);
console.log("\nUser Account State Randomized Delegated: ", txHash);
await new Promise(resolve => setTimeout(resolve, 2000));
let number = await program.account.userAccount.fetch(userAccount);
console.log("\nUser Account State Randomized Delegated: ", number.randomNumber);
console.log(" Waiting 5s for oracle callback...");
await new Promise(resolve => setTimeout(resolve, 5000));
const accountInfo = await providerEphemeralRollup.connection.getAccountInfo(userAccount);
if (accountInfo) {
const randomNumber = accountInfo.data[48];
console.log("\nUser Account Random Number: ", randomNumber);
}
});

it("Commit and undelegate from Ephemeral Rollup!", async () => {
Expand Down
85 changes: 40 additions & 45 deletions magicblock-er-example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
dependencies:
"@noble/hashes" "1.8.0"

"@noble/hashes@^1.3.1", "@noble/hashes@^1.4.0", "@noble/hashes@1.8.0":
"@noble/hashes@1.8.0", "@noble/hashes@^1.3.1", "@noble/hashes@^1.4.0":
version "1.8.0"
resolved "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz"
integrity sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==
Expand Down Expand Up @@ -108,14 +108,6 @@
"@solana/codecs-numbers" "2.0.0-rc.1"
"@solana/errors" "2.0.0-rc.1"

"@solana/codecs-numbers@^2.1.0":
version "2.3.0"
resolved "https://registry.npmjs.org/@solana/codecs-numbers/-/codecs-numbers-2.3.0.tgz"
integrity sha512-jFvvwKJKffvG7Iz9dmN51OGB7JBcy2CJ6Xf3NqD/VP90xak66m/Lg48T01u5IQ/hc15mChVHiBm+HHuOFDUrQg==
dependencies:
"@solana/codecs-core" "2.3.0"
"@solana/errors" "2.3.0"

"@solana/codecs-numbers@2.0.0-rc.1":
version "2.0.0-rc.1"
resolved "https://registry.npmjs.org/@solana/codecs-numbers/-/codecs-numbers-2.0.0-rc.1.tgz"
Expand All @@ -124,6 +116,14 @@
"@solana/codecs-core" "2.0.0-rc.1"
"@solana/errors" "2.0.0-rc.1"

"@solana/codecs-numbers@^2.1.0":
version "2.3.0"
resolved "https://registry.npmjs.org/@solana/codecs-numbers/-/codecs-numbers-2.3.0.tgz"
integrity sha512-jFvvwKJKffvG7Iz9dmN51OGB7JBcy2CJ6Xf3NqD/VP90xak66m/Lg48T01u5IQ/hc15mChVHiBm+HHuOFDUrQg==
dependencies:
"@solana/codecs-core" "2.3.0"
"@solana/errors" "2.3.0"

"@solana/codecs-strings@2.0.0-rc.1":
version "2.0.0-rc.1"
resolved "https://registry.npmjs.org/@solana/codecs-strings/-/codecs-strings-2.0.0-rc.1.tgz"
Expand Down Expand Up @@ -196,7 +196,7 @@
"@solana/spl-token-metadata" "^0.1.6"
buffer "^6.0.3"

"@solana/web3.js@^1.32.0", "@solana/web3.js@^1.69.0", "@solana/web3.js@^1.95.3", "@solana/web3.js@^1.95.5", "@solana/web3.js@^1.98.0":
"@solana/web3.js@^1.32.0", "@solana/web3.js@^1.69.0", "@solana/web3.js@^1.98.0":
version "1.98.4"
resolved "https://registry.npmjs.org/@solana/web3.js/-/web3.js-1.98.4.tgz"
integrity sha512-vv9lfnvjUsRiq//+j5pBdXig0IQdtzA0BRZ3bXEP4KaIyF1CcaydWqgyzQgfZMNIsWNWmG+AUHwPy4AHOD6gpw==
Expand Down Expand Up @@ -440,7 +440,7 @@ buffer-layout@^1.2.0, buffer-layout@^1.2.2:
resolved "https://registry.npmjs.org/buffer-layout/-/buffer-layout-1.2.2.tgz"
integrity sha512-kWSuLN694+KTk8SrYvCqwP2WcgQjoRCiF5b4QDvkkz8EmgD+aWAIceGFKMIAdmF/pH+vpgNV3d3kAKorcdAmWA==

buffer@^6.0.3, buffer@~6.0.3, buffer@6.0.3:
buffer@6.0.3, buffer@^6.0.3, buffer@~6.0.3:
version "6.0.3"
resolved "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz"
integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==
Expand Down Expand Up @@ -580,16 +580,16 @@ delay@^5.0.0:
resolved "https://registry.npmjs.org/delay/-/delay-5.0.0.tgz"
integrity sha512-ReEBKkIfe4ya47wlPYf/gu5ib6yUG0/Aez0JQZQz94kiWtRQvZIQbTiehsnwHvLSWJnQdhVeqYue7Id1dKr0qw==

diff@^3.1.0:
version "3.5.0"
resolved "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz"
integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==

diff@5.0.0:
version "5.0.0"
resolved "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz"
integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==

diff@^3.1.0:
version "3.5.0"
resolved "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz"
integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==

emoji-regex@^8.0.0:
version "8.0.0"
resolved "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz"
Expand Down Expand Up @@ -637,11 +637,6 @@ fast-stable-stringify@^1.0.0:
resolved "https://registry.npmjs.org/fast-stable-stringify/-/fast-stable-stringify-1.0.0.tgz"
integrity sha512-wpYMUmFu5f00Sm0cj2pfivpmawLZ0NKdviQ4w9zJeR8JVtOpOxHmLaJuj0vxvGqMJQWyP/COUkF75/57OKyRag==

fastestsmallesttextencoderdecoder@^1.0.22:
version "1.0.22"
resolved "https://registry.npmjs.org/fastestsmallesttextencoderdecoder/-/fastestsmallesttextencoderdecoder-1.0.22.tgz"
integrity sha512-Pb8d48e+oIuY4MaM64Cd7OW1gt4nxCHs7/ddPPZ/Ic3sg8yVGM7O9wDvZ7us6ScaUupzM+pfBolwtYhN1IxBIw==

file-uri-to-path@1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz"
Expand Down Expand Up @@ -859,20 +854,20 @@ make-error@^1.1.1:
resolved "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz"
integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==

minimatch@^3.0.4:
version "3.1.2"
resolved "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz"
integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==
dependencies:
brace-expansion "^1.1.7"

minimatch@4.2.1:
version "4.2.1"
resolved "https://registry.npmjs.org/minimatch/-/minimatch-4.2.1.tgz"
integrity sha512-9Uq1ChtSZO+Mxa/CL1eGizn2vRn3MlLgzhT0Iz8zaY8NdvxvB0d5QdPFmCKf7JKA9Lerx5vRrnwO03jsSfGG9g==
dependencies:
brace-expansion "^1.1.7"

minimatch@^3.0.4:
version "3.1.2"
resolved "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz"
integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==
dependencies:
brace-expansion "^1.1.7"

minimist@^1.2.0, minimist@^1.2.6:
version "1.2.8"
resolved "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz"
Expand All @@ -885,7 +880,7 @@ mkdirp@^0.5.1:
dependencies:
minimist "^1.2.6"

"mocha@^3.X.X || ^4.X.X || ^5.X.X || ^6.X.X || ^7.X.X || ^8.X.X || ^9.X.X || ^10.X.X || ^11.X.X", mocha@^9.0.3:
mocha@^9.0.3:
version "9.2.2"
resolved "https://registry.npmjs.org/mocha/-/mocha-9.2.2.tgz"
integrity sha512-L6XC3EdwT6YrIk0yXpavvLkn8h+EU+Y5UcCHKECyMbdUIxyMuZj4bX4U9e1nvnvUUvQVsV2VHQr5zLdcUkhW/g==
Expand Down Expand Up @@ -915,16 +910,16 @@ mkdirp@^0.5.1:
yargs-parser "20.2.4"
yargs-unparser "2.0.0"

ms@^2.0.0, ms@2.1.3:
version "2.1.3"
resolved "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz"
integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==

ms@2.1.2:
version "2.1.2"
resolved "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz"
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==

ms@2.1.3, ms@^2.0.0:
version "2.1.3"
resolved "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz"
integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==

nanoid@3.3.1:
version "3.3.1"
resolved "https://registry.npmjs.org/nanoid/-/nanoid-3.3.1.tgz"
Expand Down Expand Up @@ -1106,20 +1101,20 @@ superstruct@^2.0.2:
resolved "https://registry.npmjs.org/superstruct/-/superstruct-2.0.2.tgz"
integrity sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A==

supports-color@^7.1.0:
version "7.2.0"
resolved "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz"
integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==
dependencies:
has-flag "^4.0.0"

supports-color@8.1.1:
version "8.1.1"
resolved "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz"
integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==
dependencies:
has-flag "^4.0.0"

supports-color@^7.1.0:
version "7.2.0"
resolved "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz"
integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==
dependencies:
has-flag "^4.0.0"

text-encoding-utf-8@^1.0.2:
version "1.0.2"
resolved "https://registry.npmjs.org/text-encoding-utf-8/-/text-encoding-utf-8-1.0.2.tgz"
Expand Down Expand Up @@ -1185,7 +1180,7 @@ type-detect@^4.0.0, type-detect@^4.1.0:
resolved "https://registry.npmjs.org/type-detect/-/type-detect-4.1.0.tgz"
integrity sha512-Acylog8/luQ8L7il+geoSxhEkazvkslg7PSNKOX59mbB9cOveP5aq9h74Y7YU8yDpJwetzQQrfIwtf4Wp4LKcw==

typescript@^5.3.0, typescript@^5.7.3, typescript@>=5, typescript@>=5.3.3:
typescript@^5.3.0, typescript@^5.7.3:
version "5.9.2"
resolved "https://registry.npmjs.org/typescript/-/typescript-5.9.2.tgz"
integrity sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==
Expand All @@ -1195,7 +1190,7 @@ undici-types@~7.12.0:
resolved "https://registry.npmjs.org/undici-types/-/undici-types-7.12.0.tgz"
integrity sha512-goOacqME2GYyOZZfb5Lgtu+1IDmAlAEu5xnD3+xTzS10hT0vzpf0SPjkXwAw9Jm+4n/mQGDP3LO8CPbYROeBfQ==

utf-8-validate@^5.0.2, utf-8-validate@>=5.0.2:
utf-8-validate@^5.0.2:
version "5.0.10"
resolved "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.10.tgz"
integrity sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ==
Expand Down Expand Up @@ -1246,7 +1241,7 @@ wrappy@1:
resolved "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz"
integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==

ws@*, ws@^7.5.10:
ws@^7.5.10:
version "7.5.10"
resolved "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz"
integrity sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==
Expand All @@ -1261,7 +1256,7 @@ y18n@^5.0.5:
resolved "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz"
integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==

yargs-parser@^20.2.2, yargs-parser@20.2.4:
yargs-parser@20.2.4, yargs-parser@^20.2.2:
version "20.2.4"
resolved "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz"
integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==
Expand Down