From 9d348f2a2eac49b01fce37a1b6dcac8a9512eb3d Mon Sep 17 00:00:00 2001 From: Gabriele Picco Date: Sun, 28 Jan 2024 22:28:51 +0100 Subject: [PATCH 1/6] :sparkles: Modify macro to allow [bolt_account] macro without component_id --- crates/bolt-lang/attribute/account/src/lib.rs | 58 +++++++++---------- .../bolt-lang/attribute/component/src/lib.rs | 2 +- examples/component-position/src/lib.rs | 2 +- tests/bolt.ts | 4 +- 4 files changed, 31 insertions(+), 35 deletions(-) diff --git a/crates/bolt-lang/attribute/account/src/lib.rs b/crates/bolt-lang/attribute/account/src/lib.rs index 6f28684..e08c6bc 100644 --- a/crates/bolt-lang/attribute/account/src/lib.rs +++ b/crates/bolt-lang/attribute/account/src/lib.rs @@ -1,6 +1,5 @@ use proc_macro::TokenStream; use quote::quote; -use syn::spanned::Spanned; use syn::{parse_macro_input, parse_quote, Attribute, DeriveInput, Lit, Meta, NestedMeta}; /// This BoltAccount attribute is used to automatically generate the seed and size functions @@ -9,7 +8,7 @@ use syn::{parse_macro_input, parse_quote, Attribute, DeriveInput, Lit, Meta, Nes /// The macro also adds the InitSpace and Default derives to the struct. /// /// #[account] -/// #[bolt_account(component_id = "bolt-position")] +/// #[bolt_account] /// pub struct Position { /// pub x: i64, /// pub y: i64, @@ -18,45 +17,42 @@ use syn::{parse_macro_input, parse_quote, Attribute, DeriveInput, Lit, Meta, Nes /// ``` #[proc_macro_attribute] pub fn bolt_account(attr: TokenStream, item: TokenStream) -> TokenStream { - let attr = parse_macro_input!(attr as Meta); let mut input = parse_macro_input!(item as DeriveInput); + let mut component_id_value = None; - let component_id_value = match attr { - Meta::NameValue(meta_name_value) if meta_name_value.path.is_ident("component_id") => { - if let Lit::Str(lit) = meta_name_value.lit { - Some(lit.value()) - } else { - None + if !attr.is_empty() { + + let attr_meta = parse_macro_input!(attr as Meta); + + component_id_value = match attr_meta { + Meta::Path(_) => None, + Meta::NameValue(meta_name_value) if meta_name_value.path.is_ident("component_id") => { + if let Lit::Str(lit) = meta_name_value.lit { + Some(lit.value()) + } else { + None + } } - } - Meta::List(meta) => meta.nested.into_iter().find_map(|nested_meta| { - if let NestedMeta::Meta(Meta::NameValue(meta_name_value)) = nested_meta { - if meta_name_value.path.is_ident("component_id") { - if let Lit::Str(lit) = meta_name_value.lit { - Some(lit.value()) + Meta::List(meta) => meta.nested.into_iter().find_map(|nested_meta| { + if let NestedMeta::Meta(Meta::NameValue(meta_name_value)) = nested_meta { + if meta_name_value.path.is_ident("component_id") { + if let Lit::Str(lit) = meta_name_value.lit { + Some(lit.value()) + } else { + None + } } else { None } } else { None } - } else { - None - } - }), - _ => { - let error = syn::Error::new(attr.span(), "Missing required attribute `component_id`"); - return error.to_compile_error().into(); - } - }; + }), + _ => None + }; + } - let component_id_value = match component_id_value { - Some(value) => value, - None => { - let error = syn::Error::new(input.span(), "The `component_id` attribute is required"); - return error.to_compile_error().into(); - } - }; + let component_id_value = component_id_value.unwrap_or_else(|| "".to_string()); let additional_derives: Attribute = parse_quote! { #[derive(InitSpace, Default)] }; input.attrs.push(additional_derives); diff --git a/crates/bolt-lang/attribute/component/src/lib.rs b/crates/bolt-lang/attribute/component/src/lib.rs index b153814..cdc8256 100644 --- a/crates/bolt-lang/attribute/component/src/lib.rs +++ b/crates/bolt-lang/attribute/component/src/lib.rs @@ -19,7 +19,7 @@ use syn::{ /// } /// /// #[account] -/// #[bolt_account(component_id = "bolt-position")] +/// #[bolt_account] /// pub struct Position { /// pub x: i64, /// pub y: i64, diff --git a/examples/component-position/src/lib.rs b/examples/component-position/src/lib.rs index 1f5287d..e37aa3c 100644 --- a/examples/component-position/src/lib.rs +++ b/examples/component-position/src/lib.rs @@ -9,7 +9,7 @@ pub mod component_position { } #[account] -#[bolt_account(component_id = "component-position")] +#[bolt_account] #[derive(Copy)] pub struct Position { pub x: i64, diff --git a/tests/bolt.ts b/tests/bolt.ts index fe31ef5..587b923 100644 --- a/tests/bolt.ts +++ b/tests/bolt.ts @@ -189,7 +189,7 @@ describe("bolt", () => { componentPositionEntity1 = FindComponentPda( boltComponentPositionProgram.programId, entity1, - "component-position" + "" ); console.log("Component Position E1: ", componentPositionEntity1.toBase58()); @@ -227,7 +227,7 @@ describe("bolt", () => { componentPositionEntity2 = FindComponentPda( boltComponentPositionProgram.programId, entity2, - "component-position" + "" ); await worldProgram.methods From 9f84e9df4e83ecc10c766c49a6c85ae82cd9522a Mon Sep 17 00:00:00 2001 From: Gabriele Picco Date: Sun, 28 Jan 2024 22:46:06 +0100 Subject: [PATCH 2/6] :sparkles: Update client SDK to use default component id --- clients/bolt-sdk/lib/index.d.ts | 2 +- clients/bolt-sdk/lib/index.d.ts.map | 2 +- clients/bolt-sdk/lib/index.js | 3 + clients/bolt-sdk/lib/index.js.map | 2 +- clients/bolt-sdk/package.json | 2 +- clients/bolt-sdk/src/generated/index.ts | 2 +- crates/bolt-lang/attribute/account/src/lib.rs | 3 +- tests/bolt.ts | 88 +++++++------------ 8 files changed, 39 insertions(+), 65 deletions(-) diff --git a/clients/bolt-sdk/lib/index.d.ts b/clients/bolt-sdk/lib/index.d.ts index 7dd81d9..7bb5de3 100644 --- a/clients/bolt-sdk/lib/index.d.ts +++ b/clients/bolt-sdk/lib/index.d.ts @@ -16,6 +16,6 @@ export declare function FindEntityPda( export declare function FindComponentPda( componentProgramId: PublicKey, entity: PublicKey, - componentId: string + componentId?: string ): PublicKey; //# sourceMappingURL=index.d.ts.map diff --git a/clients/bolt-sdk/lib/index.d.ts.map b/clients/bolt-sdk/lib/index.d.ts.map index cd67f15..476a490 100644 --- a/clients/bolt-sdk/lib/index.d.ts.map +++ b/clients/bolt-sdk/lib/index.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/generated/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,OAAO,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAQ/B,eAAO,MAAM,eAAe,gDAAgD,CAAC;AAQ7E,eAAO,MAAM,UAAU,WAAiC,CAAC;AAEzD,wBAAgB,oBAAoB,CAClC,SAAS,GAAE,SAAqC,aAMjD;AAED,wBAAgB,YAAY,CAC1B,EAAE,EAAE,EAAE,EACN,SAAS,GAAE,SAAqC,aAMjD;AAED,wBAAgB,aAAa,CAC3B,OAAO,EAAE,EAAE,EACX,QAAQ,EAAE,EAAE,EACZ,SAAS,CAAC,EAAE,MAAM,EAClB,SAAS,GAAE,SAAqC,aAUjD;AAED,wBAAgB,gBAAgB,CAC9B,kBAAkB,EAAE,SAAS,EAC7B,MAAM,EAAE,SAAS,EACjB,WAAW,EAAE,MAAM,aAMpB"} \ No newline at end of file +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/generated/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,OAAO,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAQ/B,eAAO,MAAM,eAAe,gDAAgD,CAAC;AAQ7E,eAAO,MAAM,UAAU,WAAiC,CAAC;AAEzD,wBAAgB,oBAAoB,CAClC,SAAS,GAAE,SAAqC,aAMjD;AAED,wBAAgB,YAAY,CAC1B,EAAE,EAAE,EAAE,EACN,SAAS,GAAE,SAAqC,aAMjD;AAED,wBAAgB,aAAa,CAC3B,OAAO,EAAE,EAAE,EACX,QAAQ,EAAE,EAAE,EACZ,SAAS,CAAC,EAAE,MAAM,EAClB,SAAS,GAAE,SAAqC,aAUjD;AAED,wBAAgB,gBAAgB,CAC5B,kBAAkB,EAAE,SAAS,EAC7B,MAAM,EAAE,SAAS,EACjB,WAAW,GAAE,MAAW,aAM3B"} \ No newline at end of file diff --git a/clients/bolt-sdk/lib/index.js b/clients/bolt-sdk/lib/index.js index 895abe2..5c411a1 100644 --- a/clients/bolt-sdk/lib/index.js +++ b/clients/bolt-sdk/lib/index.js @@ -77,6 +77,9 @@ function FindEntityPda(worldId, entityId, extraSeed, programId) { } exports.FindEntityPda = FindEntityPda; function FindComponentPda(componentProgramId, entity, componentId) { + if (componentId === void 0) { + componentId = ""; + } return web3_js_1.PublicKey.findProgramAddressSync( [Buffer.from(componentId), entity.toBytes()], componentProgramId diff --git a/clients/bolt-sdk/lib/index.js.map b/clients/bolt-sdk/lib/index.js.map index 6ccad27..d66c36d 100644 --- a/clients/bolt-sdk/lib/index.js.map +++ b/clients/bolt-sdk/lib/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/generated/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAA4C;AAE5C,6CAA2B;AAC3B,iDAA+B;AAQlB,QAAA,eAAe,GAAG,6CAA6C,CAAC;AAQhE,QAAA,UAAU,GAAG,IAAI,mBAAS,CAAC,uBAAe,CAAC,CAAC;AAEzD,SAAgB,oBAAoB,CAClC,SAAgD;IAAhD,0BAAA,EAAA,gBAA2B,mBAAS,CAAC,kBAAU,CAAC;IAEhD,OAAO,mBAAS,CAAC,sBAAsB,CACrC,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,EACzB,SAAS,CACV,CAAC,CAAC,CAAC,CAAC;AACP,CAAC;AAPD,oDAOC;AAED,SAAgB,YAAY,CAC1B,EAAM,EACN,SAAgD;IAAhD,0BAAA,EAAA,gBAA2B,mBAAS,CAAC,kBAAU,CAAC;IAEhD,OAAO,mBAAS,CAAC,sBAAsB,CACrC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAC5C,SAAS,CACV,CAAC,CAAC,CAAC,CAAC;AACP,CAAC;AARD,oCAQC;AAED,SAAgB,aAAa,CAC3B,OAAW,EACX,QAAY,EACZ,SAAkB,EAClB,SAAgD;IAAh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;IAE1B,OAAO,mBAAS,CAAC,sBAAsB,CACrC,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,EAC5C,kBAAkB,CACnB,CAAC,CAAC,CAAC,CAAC;AACP,CAAC;AATD,4CASC"} \ No newline at end of file diff --git a/clients/bolt-sdk/package.json b/clients/bolt-sdk/package.json index 453f647..71d5518 100644 --- a/clients/bolt-sdk/package.json +++ b/clients/bolt-sdk/package.json @@ -1,6 +1,6 @@ { "name": "bolt-sdk", - "version": "0.0.9", + "version": "0.0.10", "description": "Bolt typescript SDK", "author": "dev@magicblock.gg", "license": "MIT", diff --git a/clients/bolt-sdk/src/generated/index.ts b/clients/bolt-sdk/src/generated/index.ts index 3a1bec2..6273b2d 100644 --- a/clients/bolt-sdk/src/generated/index.ts +++ b/clients/bolt-sdk/src/generated/index.ts @@ -57,7 +57,7 @@ export function FindEntityPda( export function FindComponentPda( componentProgramId: PublicKey, entity: PublicKey, - componentId: string + componentId: string = "" ) { return PublicKey.findProgramAddressSync( [Buffer.from(componentId), entity.toBytes()], diff --git a/crates/bolt-lang/attribute/account/src/lib.rs b/crates/bolt-lang/attribute/account/src/lib.rs index e08c6bc..57856bc 100644 --- a/crates/bolt-lang/attribute/account/src/lib.rs +++ b/crates/bolt-lang/attribute/account/src/lib.rs @@ -21,7 +21,6 @@ pub fn bolt_account(attr: TokenStream, item: TokenStream) -> TokenStream { let mut component_id_value = None; if !attr.is_empty() { - let attr_meta = parse_macro_input!(attr as Meta); component_id_value = match attr_meta { @@ -48,7 +47,7 @@ pub fn bolt_account(attr: TokenStream, item: TokenStream) -> TokenStream { None } }), - _ => None + _ => None, }; } diff --git a/tests/bolt.ts b/tests/bolt.ts index 587b923..69d343f 100644 --- a/tests/bolt.ts +++ b/tests/bolt.ts @@ -10,6 +10,12 @@ import { SystemApplyVelocity } from "../target/types/system_apply_velocity"; import { World } from "../target/types/world"; import { expect } from "chai"; import BN from "bn.js"; +import { + FindComponentPda, + FindEntityPda, + FindWorldPda, + FindWorldRegistryPda, +} from "../clients/bolt-sdk"; enum Direction { Left = "Left", @@ -57,7 +63,7 @@ describe("bolt", () => { let componentVelocityEntity1: PublicKey; it("InitializeWorldsRegistry", async () => { - const registryPda = FindWorldRegistryPda(worldProgram); + const registryPda = FindWorldRegistryPda(worldProgram.programId); await worldProgram.methods .initializeRegistry() .accounts({ @@ -68,9 +74,9 @@ describe("bolt", () => { }); it("InitializeNewWorld", async () => { - const registryPda = FindWorldRegistryPda(worldProgram); + const registryPda = FindWorldRegistryPda(worldProgram.programId); - const worldPda = FindWorldPda(worldProgram, new BN(0)); + const worldPda = FindWorldPda(new BN(0), worldProgram.programId); await worldProgram.methods .initializeNewWorld() .accounts({ @@ -82,9 +88,9 @@ describe("bolt", () => { }); it("InitializeNewWorld 2", async () => { - const registryPda = FindWorldRegistryPda(worldProgram); + const registryPda = FindWorldRegistryPda(worldProgram.programId); - const worldPda = FindWorldPda(worldProgram, new BN(1)); + const worldPda = FindWorldPda(new BN(1), worldProgram.programId); await worldProgram.methods .initializeNewWorld() .accounts({ @@ -96,8 +102,8 @@ describe("bolt", () => { }); it("Add entity 1", async () => { - const worldPda = FindWorldPda(worldProgram, new BN(0)); - entity1 = FindEntityPda(worldProgram, new BN(0), new BN(0)); + const worldPda = FindWorldPda(new BN(0), worldProgram.programId); + entity1 = FindEntityPda(new BN(0), new BN(0), null, worldProgram.programId); await worldProgram.methods .addEntity(null) .accounts({ @@ -109,9 +115,9 @@ describe("bolt", () => { }); it("Add entity 2", async () => { - const worldPda = FindWorldPda(worldProgram, new BN(0)); + const worldPda = FindWorldPda(new BN(0), worldProgram.programId); - entity2 = FindEntityPda(worldProgram, new BN(0), new BN(1)); + entity2 = FindEntityPda(new BN(0), new BN(1), null, worldProgram.programId); await worldProgram.methods .addEntity(null) .accounts({ @@ -123,9 +129,14 @@ describe("bolt", () => { }); it("Add entity 3", async () => { - const worldPda = FindWorldPda(worldProgram, new BN(0)); + const worldPda = FindWorldPda(new BN(0), worldProgram.programId); - const entityPda = FindEntityPda(worldProgram, new BN(0), new BN(2)); + const entityPda = FindEntityPda( + new BN(0), + new BN(2), + null, + worldProgram.programId + ); await worldProgram.methods .addEntity(null) .accounts({ @@ -137,9 +148,14 @@ describe("bolt", () => { }); it("Add entity 4 with extra seeds", async () => { - const worldPda = FindWorldPda(worldProgram, new BN(0)); + const worldPda = FindWorldPda(new BN(0), worldProgram.programId); const seed = "extra-seed"; - let entity3 = FindEntityPda(worldProgram, new BN(0), new BN(3), seed); + let entity3 = FindEntityPda( + new BN(0), + new BN(3), + seed, + worldProgram.programId + ); await worldProgram.methods .addEntity(seed) @@ -188,8 +204,7 @@ describe("bolt", () => { it("Initialize Position Component on Entity 1", async () => { componentPositionEntity1 = FindComponentPda( boltComponentPositionProgram.programId, - entity1, - "" + entity1 ); console.log("Component Position E1: ", componentPositionEntity1.toBase58()); @@ -464,47 +479,4 @@ describe("bolt", () => { console.log("| |"); console.log("+-----------------------------+"); }); - - // Utils - - function FindWorldRegistryPda(program: Program) { - return PublicKey.findProgramAddressSync( - [Buffer.from("registry")], - program.programId - )[0]; - } - - function FindWorldPda(program: Program, id: BN) { - return PublicKey.findProgramAddressSync( - [Buffer.from("world"), id.toBuffer("be", 8)], - program.programId - )[0]; - } - - function FindEntityPda( - program: Program, - worldId: BN, - entityId: BN, - extraSeed?: string - ) { - let seeds = [Buffer.from("entity"), worldId.toBuffer("be", 8)]; - if (extraSeed) { - seeds.push(Buffer.from(new Uint8Array(8))); - seeds.push(Buffer.from(extraSeed)); - } else { - seeds.push(entityId.toBuffer("be", 8)); - } - return PublicKey.findProgramAddressSync(seeds, program.programId)[0]; - } - - function FindComponentPda( - program: PublicKey, - entity: PublicKey, - seed: string = "component" - ) { - return PublicKey.findProgramAddressSync( - [Buffer.from(seed), entity.toBytes()], - program - )[0]; - } }); From b124157e601653d822669d5ec4ae138929c32201 Mon Sep 17 00:00:00 2001 From: Gabriele Picco Date: Mon, 29 Jan 2024 08:38:05 +0100 Subject: [PATCH 3/6] :bug: Fix dependencies --- clients/bolt-sdk/package.json | 4 ++++ clients/bolt-sdk/yarn.lock | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/clients/bolt-sdk/package.json b/clients/bolt-sdk/package.json index 71d5518..1db2e44 100644 --- a/clients/bolt-sdk/package.json +++ b/clients/bolt-sdk/package.json @@ -5,6 +5,10 @@ "author": "dev@magicblock.gg", "license": "MIT", "private": false, + "dependencies": { + "@metaplex-foundation/beet": "^0.7.1", + "@metaplex-foundation/beet-solana": "^0.4.0" + }, "devDependencies": { "@metaplex-foundation/solita": "^0.20.1", "@typescript-eslint/eslint-plugin": "^6.14.0", diff --git a/clients/bolt-sdk/yarn.lock b/clients/bolt-sdk/yarn.lock index 5b76eb5..69cec65 100644 --- a/clients/bolt-sdk/yarn.lock +++ b/clients/bolt-sdk/yarn.lock @@ -87,6 +87,16 @@ bs58 "^5.0.0" debug "^4.3.4" +"@metaplex-foundation/beet-solana@^0.4.0": + version "0.4.1" + resolved "https://registry.yarnpkg.com/@metaplex-foundation/beet-solana/-/beet-solana-0.4.1.tgz#255747aa7feee1c20202146a752c057feca1948f" + integrity sha512-/6o32FNUtwK8tjhotrvU/vorP7umBuRFvBZrC6XCk51aKidBHe5LPVPA5AjGPbV3oftMfRuXPNd9yAGeEqeCDQ== + dependencies: + "@metaplex-foundation/beet" ">=0.1.0" + "@solana/web3.js" "^1.56.2" + bs58 "^5.0.0" + debug "^4.3.4" + "@metaplex-foundation/beet@>=0.1.0", "@metaplex-foundation/beet@^0.7.1": version "0.7.1" resolved "https://registry.npmjs.org/@metaplex-foundation/beet/-/beet-0.7.1.tgz" @@ -2169,6 +2179,7 @@ spok@^1.4.3: find-process "^1.4.7" "string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0: + name string-width-cjs version "4.2.3" resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== From 7ca5741d46e6288a163287425122f81ba349f9a5 Mon Sep 17 00:00:00 2001 From: Gabriele Picco Date: Mon, 29 Jan 2024 09:06:13 +0100 Subject: [PATCH 4/6] :bug: Fix dependencies --- package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package.json b/package.json index fd50697..653eb73 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,8 @@ "eslint": "^8.33.0", "eslint-config-prettier": "^8.6.0", "eslint-config-standard-with-typescript": "^34.0.0", + "@metaplex-foundation/beet": "^0.7.1", + "@metaplex-foundation/beet-solana": "^0.4.0", "eslint-plugin-import": "^2.25.3", "eslint-plugin-n": "^15.6.1", "eslint-plugin-prettier": "^4.2.1", From 54a757f3ab54c842b0d31bb40d5f13750767b5f7 Mon Sep 17 00:00:00 2001 From: Gabriele Picco Date: Mon, 29 Jan 2024 09:28:31 +0100 Subject: [PATCH 5/6] :bug: Update yarn.lock --- yarn.lock | 132 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 124 insertions(+), 8 deletions(-) diff --git a/yarn.lock b/yarn.lock index 4af143c..c7770cc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14,6 +14,13 @@ dependencies: regenerator-runtime "^0.14.0" +"@babel/runtime@^7.23.4": + version "7.23.9" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.23.9.tgz#47791a15e4603bb5f905bc0753801cf21d6345f7" + integrity sha512-0CX6F+BI2s9dkUqr08KFrAIZgNFj75rdBU/DjCyYLIaV/quFjkk6T+EJ2LkZHyZTbEV4L5p97mNkUsHl2wLFAw== + dependencies: + regenerator-runtime "^0.14.0" + "@coral-xyz/anchor@^0.29.0": version "0.29.0" resolved "https://registry.yarnpkg.com/@coral-xyz/anchor/-/anchor-0.29.0.tgz#bd0be95bedfb30a381c3e676e5926124c310ff12" @@ -93,6 +100,26 @@ resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-2.0.1.tgz#e5211452df060fa8522b55c7b3c0c4d1981cb044" integrity sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw== +"@metaplex-foundation/beet-solana@^0.4.0": + version "0.4.1" + resolved "https://registry.yarnpkg.com/@metaplex-foundation/beet-solana/-/beet-solana-0.4.1.tgz#255747aa7feee1c20202146a752c057feca1948f" + integrity sha512-/6o32FNUtwK8tjhotrvU/vorP7umBuRFvBZrC6XCk51aKidBHe5LPVPA5AjGPbV3oftMfRuXPNd9yAGeEqeCDQ== + dependencies: + "@metaplex-foundation/beet" ">=0.1.0" + "@solana/web3.js" "^1.56.2" + bs58 "^5.0.0" + debug "^4.3.4" + +"@metaplex-foundation/beet@>=0.1.0", "@metaplex-foundation/beet@^0.7.1": + version "0.7.2" + resolved "https://registry.yarnpkg.com/@metaplex-foundation/beet/-/beet-0.7.2.tgz#fa4726e4cfd4fb6fed6cddc9b5213c1c2a2d0b77" + integrity sha512-K+g3WhyFxKPc0xIvcIjNyV1eaTVJTiuaHZpig7Xx0MuYRMoJLLvhLTnUXhFdR5Tu2l2QSyKwfyXDgZlzhULqFg== + dependencies: + ansicolors "^0.3.2" + assert "^2.1.0" + bn.js "^5.2.0" + debug "^4.3.3" + "@noble/curves@^1.2.0": version "1.2.0" resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.2.0.tgz#92d7e12e4e49b23105a2555c6984d41733d65c35" @@ -105,6 +132,11 @@ resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.2.tgz#6f26dbc8fbc7205873ce3cee2f690eba0d421b39" integrity sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ== +"@noble/hashes@^1.3.2": + version "1.3.3" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.3.tgz#39908da56a4adc270147bb07968bf3b16cfe1699" + integrity sha512-V7/fPHgl+jsVPXqqeOzT8egNj2iBIVt+ECeMMG8TdcnTikP3oaBtUVqpT/gYCR68aEBJSF+XbYUxStjbFMqIIA== + "@nodelib/fs.scandir@2.1.5": version "2.1.5" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" @@ -126,13 +158,34 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" -"@solana/buffer-layout@^4.0.0": +"@solana/buffer-layout@^4.0.0", "@solana/buffer-layout@^4.0.1": version "4.0.1" resolved "https://registry.yarnpkg.com/@solana/buffer-layout/-/buffer-layout-4.0.1.tgz#b996235eaec15b1e0b5092a8ed6028df77fa6c15" integrity sha512-E1ImOIAD1tBZFRdjeM4/pzTiTApC0AOBGwyAMS4fwIodCWArzJ3DWdoh8cKxeFM2fElkxBh2Aqts1BPC373rHA== dependencies: buffer "~6.0.3" +"@solana/web3.js@^1.56.2": + version "1.89.1" + resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.89.1.tgz#52df6820f2d088c4558aa359af40580a03d10ec9" + integrity sha512-t9TTLtPQxtQB3SAf/5E8xPXfVDsC6WGOsgKY02l2cbe0HLymT7ynE8Hu48Lk5qynHCquj6nhISfEHcjMkYpu/A== + dependencies: + "@babel/runtime" "^7.23.4" + "@noble/curves" "^1.2.0" + "@noble/hashes" "^1.3.2" + "@solana/buffer-layout" "^4.0.1" + agentkeepalive "^4.5.0" + bigint-buffer "^1.1.5" + bn.js "^5.2.1" + borsh "^0.7.0" + bs58 "^4.0.1" + buffer "6.0.3" + fast-stable-stringify "^1.0.0" + jayson "^4.1.0" + node-fetch "^2.7.0" + rpc-websockets "^7.5.1" + superstruct "^0.14.2" + "@solana/web3.js@^1.68.0": version "1.87.2" resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.87.2.tgz#d83484ab576f421342138ca1e0b98d2b9cfc6a00" @@ -324,7 +377,7 @@ acorn@^8.9.0: resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.11.2.tgz#ca0d78b51895be5390a5903c5b3bdcdaf78ae40b" integrity sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w== -agentkeepalive@^4.3.0: +agentkeepalive@^4.3.0, agentkeepalive@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/agentkeepalive/-/agentkeepalive-4.5.0.tgz#2673ad1389b3c418c5a20c5d7364f93ca04be923" integrity sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew== @@ -358,6 +411,11 @@ ansi-styles@^4.0.0, ansi-styles@^4.1.0: dependencies: color-convert "^2.0.1" +ansicolors@^0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/ansicolors/-/ansicolors-0.3.2.tgz#665597de86a9ffe3aa9bfbe6cae5c6ea426b4979" + integrity sha512-QXu7BPrP29VllRxH8GwB7x5iX5qWKAAMLqKQGWTeLWVlNHNOpVMJ91dsxQAIWXpjuW5wqvxu3Jd/nRjrJ+0pqg== + anymatch@~3.1.2: version "3.1.3" resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e" @@ -455,6 +513,17 @@ arrify@^1.0.0: resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" integrity sha512-3CYzex9M9FGQjCGMGyi6/31c8GJbgb0qGyrx5HWxPd0aCwh4cB2YjMb2Xf9UuoogrMrlO9cTqnB5rI5GHZTcUA== +assert@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/assert/-/assert-2.1.0.tgz#6d92a238d05dc02e7427c881fb8be81c8448b2dd" + integrity sha512-eLHpSK/Y4nhMJ07gDaAzoX/XAKS8PSaojml3M0DM4JpV1LAi5JOJ/p6H/XWrl8L+DzVEvVCW1z3vWAaB9oTsQw== + dependencies: + call-bind "^1.0.2" + is-nan "^1.3.2" + object-is "^1.1.5" + object.assign "^4.1.4" + util "^0.12.5" + assertion-error@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b" @@ -484,6 +553,11 @@ base-x@^3.0.2: dependencies: safe-buffer "^5.0.1" +base-x@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/base-x/-/base-x-4.0.0.tgz#d0e3b7753450c73f8ad2389b5c018a4af7b2224a" + integrity sha512-FuwxlW4H5kh37X/oW59pwTzzTKRzfrrQwhmyspRM7swOEZcHtDZSCt45U6oKgtuFE+WYPblePMVIPR4RZrh/hw== + base64-js@^1.3.1: version "1.5.1" resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" @@ -549,6 +623,13 @@ bs58@^4.0.0, bs58@^4.0.1: dependencies: base-x "^3.0.2" +bs58@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/bs58/-/bs58-5.0.0.tgz#865575b4d13c09ea2a84622df6c8cbeb54ffc279" + integrity sha512-r+ihvQJvahgYT50JD05dyJNKlmmSlMoOGwn1lCcEzanPglg7TxYjioQUYehQ9mAR/+hOSd2jRc/Z2y5UxBymvQ== + dependencies: + base-x "^4.0.0" + buffer-from@^1.0.0, buffer-from@^1.1.0: version "1.1.2" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" @@ -709,7 +790,7 @@ debug@^3.2.7: dependencies: ms "^2.1.1" -debug@^4.1.1, debug@^4.3.2, debug@^4.3.4: +debug@^4.1.1, debug@^4.3.2, debug@^4.3.3, debug@^4.3.4: version "4.3.4" resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== @@ -1481,7 +1562,7 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2: +inherits@2, inherits@^2.0.3: version "2.0.4" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== @@ -1495,6 +1576,14 @@ internal-slot@^1.0.5: hasown "^2.0.0" side-channel "^1.0.4" +is-arguments@^1.0.4: + version "1.1.1" + resolved "https://registry.yarnpkg.com/is-arguments/-/is-arguments-1.1.1.tgz#15b3f88fda01f2a97fec84ca761a560f123efa9b" + integrity sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA== + dependencies: + call-bind "^1.0.2" + has-tostringtag "^1.0.0" + is-array-buffer@^3.0.1, is-array-buffer@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/is-array-buffer/-/is-array-buffer-3.0.2.tgz#f2653ced8412081638ecb0ebbd0c41c6e0aecbbe" @@ -1569,7 +1658,7 @@ is-fullwidth-code-point@^3.0.0: resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== -is-generator-function@^1.0.10: +is-generator-function@^1.0.10, is-generator-function@^1.0.7: version "1.0.10" resolved "https://registry.yarnpkg.com/is-generator-function/-/is-generator-function-1.0.10.tgz#f1558baf1ac17e0deea7c0415c438351ff2b3c72" integrity sha512-jsEjy9l3yiXEQ+PsXdmBwEPcOxaXWLspKdplFUVI9vq1iZgIekeC0L167qeu86czQaxed3q/Uzuw0swL0irL8A== @@ -1588,6 +1677,14 @@ is-map@^2.0.1: resolved "https://registry.yarnpkg.com/is-map/-/is-map-2.0.2.tgz#00922db8c9bf73e81b7a335827bc2a43f2b91127" integrity sha512-cOZFQQozTha1f4MxLFzlgKYPTyj26picdZTx82hbc/Xf4K/tZOOXSCkMvU4pKioRXGDLJRn0GM7Upe7kR721yg== +is-nan@^1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/is-nan/-/is-nan-1.3.2.tgz#043a54adea31748b55b6cd4e09aadafa69bd9e1d" + integrity sha512-E+zBKpQ2t6MEo1VsonYmluk9NxGrbzpeeLC2xIViuO2EjU2xsXsBPwTr3Ykv9l08UYEVEdWeRZNouaZqF6RN0w== + dependencies: + call-bind "^1.0.0" + define-properties "^1.1.3" + is-negative-zero@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/is-negative-zero/-/is-negative-zero-2.0.2.tgz#7bf6f03a28003b8b3965de3ac26f664d765f3150" @@ -1649,7 +1746,7 @@ is-symbol@^1.0.2, is-symbol@^1.0.3: dependencies: has-symbols "^1.0.2" -is-typed-array@^1.1.10, is-typed-array@^1.1.12, is-typed-array@^1.1.9: +is-typed-array@^1.1.10, is-typed-array@^1.1.12, is-typed-array@^1.1.3, is-typed-array@^1.1.9: version "1.1.12" resolved "https://registry.yarnpkg.com/is-typed-array/-/is-typed-array-1.1.12.tgz#d0bab5686ef4a76f7a73097b95470ab199c57d4a" integrity sha512-Z14TF2JNG8Lss5/HMqt0//T9JeHXttXy5pH/DBU4vi98ozO2btxzq9MwYDZYnKwU8nRsz/+GVFVRDq3DkVuSPg== @@ -1949,7 +2046,7 @@ no-case@^3.0.4: lower-case "^2.0.2" tslib "^2.0.3" -node-fetch@^2.6.12: +node-fetch@^2.6.12, node-fetch@^2.7.0: version "2.7.0" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== @@ -1976,6 +2073,14 @@ object-inspect@^1.13.1, object-inspect@^1.9.0: resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.13.1.tgz#b96c6109324ccfef6b12216a956ca4dc2ff94bc2" integrity sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ== +object-is@^1.1.5: + version "1.1.5" + resolved "https://registry.yarnpkg.com/object-is/-/object-is-1.1.5.tgz#b9deeaa5fc7f1846a0faecdceec138e5778f53ac" + integrity sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.3" + object-keys@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" @@ -2640,6 +2745,17 @@ utf-8-validate@^5.0.2: dependencies: node-gyp-build "^4.3.0" +util@^0.12.5: + version "0.12.5" + resolved "https://registry.yarnpkg.com/util/-/util-0.12.5.tgz#5f17a6059b73db61a875668781a1c2b136bd6fbc" + integrity sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA== + dependencies: + inherits "^2.0.3" + is-arguments "^1.0.4" + is-generator-function "^1.0.7" + is-typed-array "^1.1.3" + which-typed-array "^1.1.2" + uuid@^8.3.2: version "8.3.2" resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" @@ -2697,7 +2813,7 @@ which-collection@^1.0.1: is-weakmap "^2.0.1" is-weakset "^2.0.1" -which-typed-array@^1.1.11, which-typed-array@^1.1.13, which-typed-array@^1.1.9: +which-typed-array@^1.1.11, which-typed-array@^1.1.13, which-typed-array@^1.1.2, which-typed-array@^1.1.9: version "1.1.13" resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.13.tgz#870cd5be06ddb616f504e7b039c4c24898184d36" integrity sha512-P5Nra0qjSncduVPEAr7xhoF5guty49ArDTwzJ/yNuPIbZppyRxFQsRCWrocxIY+CnMVG+qfbU2FmDKyvSGClow== From 65be3e2cd2491a2d837180865de4b585445af49a Mon Sep 17 00:00:00 2001 From: Gabriele Picco Date: Mon, 29 Jan 2024 09:47:29 +0100 Subject: [PATCH 6/6] :white_check_mark: Simplify test --- tests/bolt.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/bolt.ts b/tests/bolt.ts index 69d343f..ebf04ce 100644 --- a/tests/bolt.ts +++ b/tests/bolt.ts @@ -241,8 +241,7 @@ describe("bolt", () => { it("Initialize Position Component on Entity 2", async () => { componentPositionEntity2 = FindComponentPda( boltComponentPositionProgram.programId, - entity2, - "" + entity2 ); await worldProgram.methods