diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 89ee3a2..901f6e5 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -8,8 +8,8 @@ on: branches: - master env: - SOLANA_CLI_VERSION: 1.14.17 - NODE_VERSION: 18 + SOLANA_CLI_VERSION: 1.17.18 + NODE_VERSION: 22 jobs: example-program-tests: diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..27ae62c --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "1.74.1" diff --git a/src/common.ts b/src/common.ts index 0fab322..b18e554 100644 --- a/src/common.ts +++ b/src/common.ts @@ -40,7 +40,6 @@ export function jsonInterfaceName(typeName: string) { export function isComplexType( ty: IdlType ): ty is - | IdlTypeDefined | IdlTypeArray | IdlTypeVec | IdlTypeOption @@ -125,6 +124,9 @@ export function tsTypeFromIdl( const name = kindInterfaceName(ty.defined) return `${definedTypesPrefix}${name}` } + case "alias": { + throw new Error("alias layout support not implemented") + } } } if (isComplexType(ty) && "array" in ty) { @@ -306,6 +308,9 @@ export function fieldToEncodable( case "enum": { return `${valPrefix}${ty.name}.toEncodable()` } + case "alias": { + throw new Error("alias layout support not implemented") + } } } if (isComplexType(ty.type) && "array" in ty.type) { @@ -402,6 +407,8 @@ export function fieldFromDecoded( case "struct": case "enum": return `${definedTypesPrefix}${ty.type.defined}.fromDecoded(${valPrefix}${ty.name})` + case "alias": + throw new Error("alias layout support not implemented") default: { unreachable(filtered[0].type) throw new Error("Unreachable.") @@ -469,6 +476,8 @@ export function structFieldInitializer( case "enum": filtered[0].type.kind return `${prefix}${field.name}` + case "alias": + throw new Error("alias layout support not implemented") default: unreachable(filtered[0].type) return @@ -618,6 +627,8 @@ export function fieldToJSON(idl: Idl, ty: IdlField, valPrefix = ""): string { case "struct": case "enum": return `${valPrefix}${ty.name}.toJSON()` + case "alias": + throw new Error("alias layout support not implemented") default: { unreachable(filtered[0].type) throw new Error("Unreachable.") diff --git a/src/types.ts b/src/types.ts index 72f0b02..c6cffb3 100644 --- a/src/types.ts +++ b/src/types.ts @@ -84,6 +84,8 @@ function genIndexFile( .join(" | "), }) return + case "alias": + throw new Error("alias layout support not implemented") default: unreachable(ty.type) } @@ -109,6 +111,8 @@ function genTypeFiles( genEnum(idl, src, ty.name, ty.type.variants) return } + case "alias": + throw new Error("alias layout support not implemented") default: unreachable(ty.type) } diff --git a/tests/example-program-gen/exp/types/index.ts b/tests/example-program-gen/exp/types/index.ts index f4da62a..7d35bc4 100644 --- a/tests/example-program-gen/exp/types/index.ts +++ b/tests/example-program-gen/exp/types/index.ts @@ -2,8 +2,6 @@ import * as FooEnum from "./FooEnum" export { BarStruct } from "./BarStruct" export type { BarStructFields, BarStructJSON } from "./BarStruct" -export { FooStruct } from "./FooStruct" -export type { FooStructFields, FooStructJSON } from "./FooStruct" export { FooEnum } /** Enum type */ @@ -23,3 +21,6 @@ export type FooEnumJSON = | FooEnum.OptionStructJSON | FooEnum.VecStructJSON | FooEnum.NoFieldsJSON + +export { FooStruct } from "./FooStruct" +export type { FooStructFields, FooStructJSON } from "./FooStruct" diff --git a/tests/example-program-gen/idl.json b/tests/example-program-gen/idl.json index ba5d87c..372c625 100644 --- a/tests/example-program-gen/idl.json +++ b/tests/example-program-gen/idl.json @@ -450,54 +450,6 @@ ] } }, - { - "name": "FooStruct", - "type": { - "kind": "struct", - "fields": [ - { - "name": "field1", - "type": "u8" - }, - { - "name": "field2", - "type": "u16" - }, - { - "name": "nested", - "type": { - "defined": "BarStruct" - } - }, - { - "name": "vecNested", - "type": { - "vec": { - "defined": "BarStruct" - } - } - }, - { - "name": "optionNested", - "type": { - "option": { - "defined": "BarStruct" - } - } - }, - { - "name": "enumField", - "type": { - "defined": "FooEnum" - } - }, - { - "name": "pubkeyField", - "type": "publicKey" - } - ] - } - }, { "name": "FooEnum", "docs": [ @@ -579,6 +531,54 @@ } ] } + }, + { + "name": "FooStruct", + "type": { + "kind": "struct", + "fields": [ + { + "name": "field1", + "type": "u8" + }, + { + "name": "field2", + "type": "u16" + }, + { + "name": "nested", + "type": { + "defined": "BarStruct" + } + }, + { + "name": "vecNested", + "type": { + "vec": { + "defined": "BarStruct" + } + } + }, + { + "name": "optionNested", + "type": { + "option": { + "defined": "BarStruct" + } + } + }, + { + "name": "enumField", + "type": { + "defined": "FooEnum" + } + }, + { + "name": "pubkeyField", + "type": "publicKey" + } + ] + } } ], "errors": [ diff --git a/tests/example-program/Cargo.lock b/tests/example-program/Cargo.lock index 24df01d..dfd35e5 100644 --- a/tests/example-program/Cargo.lock +++ b/tests/example-program/Cargo.lock @@ -114,7 +114,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4e2e5be518ec6053d90a2a7f26843dbee607583c779e6c8395951b9739bdfbe" dependencies = [ "anchor-syn", - "borsh-derive-internal 0.9.3", + "borsh-derive-internal 0.10.4", "proc-macro2", "quote", "syn 1.0.95", @@ -146,10 +146,11 @@ dependencies = [ "anchor-derive-accounts", "anchor-derive-serde", "anchor-derive-space", + "anchor-syn", "arrayref", "base64 0.13.0", "bincode", - "borsh 0.9.3", + "borsh 0.10.4", "bytemuck", "getrandom 0.2.10", "solana-program", diff --git a/tests/example-program/Cargo.toml b/tests/example-program/Cargo.toml index a60de98..61ab23b 100644 --- a/tests/example-program/Cargo.toml +++ b/tests/example-program/Cargo.toml @@ -2,3 +2,6 @@ members = [ "programs/*" ] + +[profile.release] +overflow-checks = true diff --git a/tests/example-program/programs/example-program/Cargo.toml b/tests/example-program/programs/example-program/Cargo.toml index a6a1d17..031d087 100644 --- a/tests/example-program/programs/example-program/Cargo.toml +++ b/tests/example-program/programs/example-program/Cargo.toml @@ -14,6 +14,7 @@ no-idl = [] no-log-ix-name = [] cpi = ["no-entrypoint"] default = [] +idl-build = ["anchor-lang/idl-build"] [dependencies] anchor-lang = "^0.29.0" diff --git a/tests/test.ts b/tests/test.ts index d5abbd8..fe09d6c 100644 --- a/tests/test.ts +++ b/tests/test.ts @@ -685,7 +685,7 @@ it("tx error", async () => { "Program 3rTQ3R4B2PxZrAyx7EUefySPgZY8RhJf16cZajbmrzp8 invoke [1]", "Program log: Instruction: CauseError", "Program log: AnchorError thrown in programs/example-program/src/lib.rs:90. Error Code: SomeError. Error Number: 6000. Error Message: Example error..", - "Program 3rTQ3R4B2PxZrAyx7EUefySPgZY8RhJf16cZajbmrzp8 consumed 2293 of 200000 compute units", + "Program 3rTQ3R4B2PxZrAyx7EUefySPgZY8RhJf16cZajbmrzp8 consumed 2304 of 200000 compute units", "Program 3rTQ3R4B2PxZrAyx7EUefySPgZY8RhJf16cZajbmrzp8 failed: custom program error: 0x1770", ]) diff --git a/tsconfig.json b/tsconfig.json index 3841b4c..c324085 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,7 +9,8 @@ "sourceMap": true, "moduleResolution": "node", "noEmit": true, - "isolatedModules": true + "isolatedModules": true, + "skipLibCheck": true }, "include": ["src", "tests", "examples"], } \ No newline at end of file