From 156a4917dcf0cd13f01193a6e062520baef45b44 Mon Sep 17 00:00:00 2001 From: Jun Jiang Date: Fri, 27 Sep 2024 22:01:08 +0800 Subject: [PATCH] Fix puppet test --- cli/src/main.rs | 2 +- extensions/puppet/Cargo.lock | 106 +++++++++--------- .../puppet/programs/puppet/src/constants.rs | 4 +- extensions/puppet/tests/puppet.ts | 8 +- 4 files changed, 61 insertions(+), 59 deletions(-) diff --git a/cli/src/main.rs b/cli/src/main.rs index 6ad7d22..08749d3 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -496,7 +496,7 @@ fn dev_create_activated_device(args: DevCreateActivatedDeviceCliArgs) { eprintln!("Device: {}", device_pubkey); eprintln!("Mint: {}", did_mint_pubkey); eprintln!("AToken: {}", did_atoken_pubkey); - println!("{},{}", did_mint_pubkey, did_atoken_pubkey); + println!("{},{},{}", device_pubkey, did_mint_pubkey, did_atoken_pubkey); } Err(err) => { eprintln!("Error: {:?}", err); diff --git a/extensions/puppet/Cargo.lock b/extensions/puppet/Cargo.lock index 5f750c0..2ae44fb 100644 --- a/extensions/puppet/Cargo.lock +++ b/extensions/puppet/Cargo.lock @@ -164,7 +164,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0bb0e0911ad4a70cab880cdd6287fe1e880a1a9d8e4e6defa8e9044b9796a6c" dependencies = [ "anchor-syn", - "borsh-derive-internal 0.10.3", + "borsh-derive-internal 0.10.4", "proc-macro2", "quote", "syn 1.0.109", @@ -200,7 +200,7 @@ dependencies = [ "arrayref", "base64 0.21.7", "bincode", - "borsh 0.10.3", + "borsh 0.10.4", "bytemuck", "getrandom 0.2.15", "solana-program", @@ -269,9 +269,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" [[package]] name = "ark-bn254" @@ -392,9 +392,9 @@ dependencies = [ [[package]] name = "arrayref" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d151e35f61089500b617991b791fc8bfd237ae50cd5950803758a179b41e67a" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" [[package]] name = "arrayvec" @@ -421,9 +421,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "base64" @@ -515,11 +515,11 @@ dependencies = [ [[package]] name = "borsh" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b" +checksum = "115e54d64eb62cdebad391c19efc9dce4981c690c85a33a12199d99bb9546fee" dependencies = [ - "borsh-derive 0.10.3", + "borsh-derive 0.10.4", "hashbrown 0.13.2", ] @@ -548,12 +548,12 @@ dependencies = [ [[package]] name = "borsh-derive" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0754613691538d51f329cce9af41d7b7ca150bc973056f1156611489475f54f7" +checksum = "831213f80d9423998dd696e2c5345aba6be7a0bd8cd19e31c5243e13df1cef89" dependencies = [ - "borsh-derive-internal 0.10.3", - "borsh-schema-derive-internal 0.10.3", + "borsh-derive-internal 0.10.4", + "borsh-schema-derive-internal 0.10.4", "proc-macro-crate 0.1.5", "proc-macro2", "syn 1.0.109", @@ -586,9 +586,9 @@ dependencies = [ [[package]] name = "borsh-derive-internal" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb438156919598d2c7bad7e1c0adf3d26ed3840dbc010db1a882a65583ca2fb" +checksum = "65d6ba50644c98714aa2a70d13d7df3cd75cd2b523a2b452bf010443800976b3" dependencies = [ "proc-macro2", "quote", @@ -608,9 +608,9 @@ dependencies = [ [[package]] name = "borsh-schema-derive-internal" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634205cc43f74a1b9046ef87c4540ebda95696ec0f315024860cad7c5b0f5ccd" +checksum = "276691d96f063427be83e6692b86148e488ebba9f48f77788724ca027ba3b6d4" dependencies = [ "proc-macro2", "quote", @@ -650,9 +650,9 @@ dependencies = [ [[package]] name = "bytemuck" -version = "1.17.1" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773d90827bc3feecfb67fab12e24de0749aad83c74b9504ecde46237b5cd24e2" +checksum = "94bbb0ad554ad961ddc5da507a12a29b14e4ae5bda06b19f575a3e6079d2e2ae" dependencies = [ "bytemuck_derive", ] @@ -686,9 +686,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.15" +version = "1.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57b6a275aa2903740dc87da01c62040406b8812552e97129a63ea8850a17c6e6" +checksum = "9540e661f81799159abee814118cc139a2004b3a3aa3ea37724a1b66530b90e0" dependencies = [ "jobserver", "libc", @@ -753,9 +753,9 @@ checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" [[package]] name = "cpufeatures" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ "libc", ] @@ -1175,9 +1175,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.158" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] name = "libsecp256k1" @@ -1297,7 +1297,7 @@ version = "4.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "caf0f61b553e424a6234af1268456972ee66c2222e1da89079242251fa7479e5" dependencies = [ - "borsh 0.10.3", + "borsh 0.10.4", "num-derive 0.3.3", "num-traits", "solana-program", @@ -1651,9 +1651,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.3" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" +checksum = "355ae415ccd3a04315d3f8246e86d67689ea74d88d915576e1589a351062a13b" dependencies = [ "bitflags", ] @@ -1728,9 +1728,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.209" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] @@ -1746,9 +1746,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.209" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", @@ -1757,9 +1757,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.127" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "itoa", "memchr", @@ -1769,9 +1769,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" +checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" dependencies = [ "serde", ] @@ -1940,7 +1940,7 @@ dependencies = [ "bincode", "bitflags", "blake3", - "borsh 0.10.3", + "borsh 0.10.4", "borsh 0.9.3", "borsh 1.5.1", "bs58 0.4.0", @@ -2348,18 +2348,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", @@ -2432,9 +2432,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.20" +version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ "indexmap", "serde", @@ -2451,24 +2451,24 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-normalization" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" dependencies = [ "tinyvec", ] [[package]] name = "unicode-segmentation" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] name = "universal-hash" @@ -2679,9 +2679,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.18" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" dependencies = [ "memchr", ] diff --git a/extensions/puppet/programs/puppet/src/constants.rs b/extensions/puppet/programs/puppet/src/constants.rs index 16abb33..5195d14 100644 --- a/extensions/puppet/programs/puppet/src/constants.rs +++ b/extensions/puppet/programs/puppet/src/constants.rs @@ -1,6 +1,6 @@ use anchor_lang::prelude::Pubkey; -pub const DEPHY_ID_PROGRAM: Pubkey = Pubkey::new_from_array([10, 104, 87, 71, 135, 225, 232, 69, 21, 185, 195, 236, 216, 23, 119, 79, 176, 27, 100, 193, 237, 38, 213, 50, 121, 184, 103, 109, 227, 77, 99, 44]); -pub const SPL_2022_PROGRAM: Pubkey = Pubkey::new_from_array([6, 221, 246, 225, 238, 117, 143, 222, 24, 66, 93, 188, 228, 108, 205, 218, 182, 26, 252, 77, 131, 185, 13, 39, 254, 189, 249, 40, 216, 161, 139, 252]); +pub const DEPHY_ID_PROGRAM: Pubkey = Pubkey::new_from_array([10u8, 104u8, 87u8, 71u8, 135u8, 225u8, 232u8, 69u8, 21u8, 185u8, 195u8, 236u8, 216u8, 23u8, 119u8, 79u8, 176u8, 27u8, 100u8, 193u8, 237u8, 38u8, 213u8, 50u8, 121u8, 184u8, 103u8, 109u8, 227u8, 77u8, 99u8, 44u8]); +pub const SPL_2022_PROGRAM: Pubkey = Pubkey::new_from_array([6u8, 221u8, 246u8, 225u8, 238u8, 117u8, 143u8, 222u8, 24u8, 66u8, 93u8, 188u8, 228u8, 108u8, 205u8, 218u8, 182u8, 26u8, 252u8, 77u8, 131u8, 185u8, 13u8, 39u8, 254u8, 189u8, 249u8, 40u8, 216u8, 161u8, 139u8, 252u8]); pub const PRODUCT_MINT_SEED_PREFIX: &[u8; 16] = b"DePHY_ID-PRODUCT"; pub const DEVICE_MINT_SEED_PREFIX: &[u8; 15] = b"DePHY_ID-DEVICE"; diff --git a/extensions/puppet/tests/puppet.ts b/extensions/puppet/tests/puppet.ts index 98627a7..d4260f5 100644 --- a/extensions/puppet/tests/puppet.ts +++ b/extensions/puppet/tests/puppet.ts @@ -75,7 +75,6 @@ describe("puppet program", () => { // write device secret key json const deviceKeypair = Keypair.generate(); - device = new PublicKey(deviceKeypair.publicKey); fs.writeFileSync(DEVICE_PATH, `[${deviceKeypair.secretKey.toString()}]`); // create product @@ -84,11 +83,13 @@ describe("puppet program", () => { product = new PublicKey(productPubkeyStr); // create activated device - const { deviceMint: deviceMintStr, deviceAta: deviceAtaStr } = await createDevice( + const { devicePubKey: devicePubKeyStr, deviceMint: deviceMintStr, deviceAta: deviceAtaStr } = await createDevice( product.toString(), ); + console.log("devicePubKey:", devicePubKeyStr); console.log("deviceMint:", deviceMintStr); console.log("deviceAta:", deviceAtaStr); + device = new PublicKey(devicePubKeyStr); deviceMint = new PublicKey(deviceMintStr); deviceAta = new PublicKey(deviceAtaStr); @@ -240,9 +241,10 @@ const createDevice = async ( command, ); - const [deviceMint, deviceAta] = str.trimEnd().split(',') + const [devicePubKey, deviceMint, deviceAta] = str.trimEnd().split(',') return { + devicePubKey, deviceMint, deviceAta, };