Skip to content

Commit

Permalink
feat: update Anchor to v0.30.0
Browse files Browse the repository at this point in the history
  • Loading branch information
beeman committed Apr 22, 2024
1 parent feca9f5 commit fabb55b
Show file tree
Hide file tree
Showing 16 changed files with 519 additions and 194 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ exports[`anchor-application generator should generate app with "basic" template
""name": "@proj/anchor-app",",
""version": "0.0.1",",
""dependencies": {",
""@coral-xyz/anchor": "^0.29.0",",
""@coral-xyz/anchor": "^0.30.0",",
""@solana/web3.js": "1.90.0"",
"},",
""type": "commonjs",",
Expand Down Expand Up @@ -226,8 +226,9 @@ exports[`anchor-application generator should generate app with "basic" template
"no-log-ix-name = []",
"cpi = ["no-entrypoint"]",
"default = []",
"idl-build = ["anchor-lang/idl-build"]",
"[dependencies]",
"anchor-lang = "0.29.0"",
"anchor-lang = "0.30.0"",
],
"isBinary": false,
"path": "anchor-app/programs/my-program/Cargo.toml",
Expand Down Expand Up @@ -344,15 +345,18 @@ exports[`anchor-application generator should generate app with "basic" template
"my-program-exports.ts": {
"content": [
"// Here we export some useful types and functions for interacting with the Anchor program.",
"import { AnchorProvider, Program } from '@coral-xyz/anchor';",
"import { PublicKey } from '@solana/web3.js';",
"import type { MyProgram } from '../target/types/my_program';",
"import { IDL as MyProgramIDL } from '../target/types/my_program';",
"// Re-export the generated IDL and type",
"export { MyProgram, MyProgramIDL };",
"// After updating your program ID (e.g. after running \`anchor keys sync\`) update the value below.",
"export const programId = new PublicKey(",
"'GMSER7ttdzFvei8hUjFrCxv3PNKje2NrPwuNYS7m15dA'",
");",
"// The programId is imported from the program IDL.",
"export const MY_PROGRAM_PROGRAM_ID = new PublicKey(MyProgramIDL.address);",
"// This is a helper function to get the MyProgram Anchor program.",
"export function getMyProgramProgram(provider: AnchorProvider) {",
"return new Program(MyProgramIDL as MyProgram, provider);",
"}",
],
"isBinary": false,
"path": "anchor-app/src/my-program-exports.ts",
Expand Down Expand Up @@ -490,7 +494,9 @@ exports[`anchor-application generator should generate app with "basic" template
""compilerOptions": {",
""outDir": "../dist/out-tsc",",
""declaration": true,",
""types": ["node"]",
""types": ["node"],",
""resolveJsonModule": true,",
""allowSyntheticDefaultImports": true",
"},",
""include": ["src/**/*.ts"],",
""exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]",
Expand Down Expand Up @@ -727,7 +733,7 @@ exports[`anchor-application generator should generate app with "counter" templat
""name": "@proj/anchor-app",",
""version": "0.0.1",",
""dependencies": {",
""@coral-xyz/anchor": "^0.29.0",",
""@coral-xyz/anchor": "^0.30.0",",
""@solana/web3.js": "1.90.0"",
"},",
""type": "commonjs",",
Expand Down Expand Up @@ -759,8 +765,9 @@ exports[`anchor-application generator should generate app with "counter" templat
"no-log-ix-name = []",
"cpi = ["no-entrypoint"]",
"default = []",
"idl-build = ["anchor-lang/idl-build"]",
"[dependencies]",
"anchor-lang = "0.29.0"",
"anchor-lang = "0.30.0"",
],
"isBinary": false,
"path": "anchor-app/programs/my-program/Cargo.toml",
Expand Down Expand Up @@ -922,15 +929,18 @@ exports[`anchor-application generator should generate app with "counter" templat
"my-program-exports.ts": {
"content": [
"// Here we export some useful types and functions for interacting with the Anchor program.",
"import { AnchorProvider, Program } from '@coral-xyz/anchor';",
"import { Cluster, PublicKey } from '@solana/web3.js';",
"import MyProgramIDL from '../target/idl/my_program.json';",
"import type { MyProgram } from '../target/types/my_program';",
"import { IDL as MyProgramIDL } from '../target/types/my_program';",
"// Re-export the generated IDL and type",
"export { MyProgram, MyProgramIDL };",
"// After updating your program ID (e.g. after running \`anchor keys sync\`) update the value below.",
"export const MY_PROGRAM_PROGRAM_ID = new PublicKey(",
"'GMSER7ttdzFvei8hUjFrCxv3PNKje2NrPwuNYS7m15dA'",
");",
"// The programId is imported from the program IDL.",
"export const MY_PROGRAM_PROGRAM_ID = new PublicKey(MyProgramIDL.address);",
"// This is a helper function to get the MyProgram Anchor program.",
"export function getMyProgramProgram(provider: AnchorProvider) {",
"return new Program(MyProgramIDL as MyProgram, provider);",
"}",
"// This is a helper function to get the program ID for the MyProgram program depending on the cluster.",
"export function getMyProgramProgramId(cluster: Cluster) {",
"switch (cluster) {",
Expand Down Expand Up @@ -1400,7 +1410,9 @@ exports[`anchor-application generator should generate app with "counter" templat
""compilerOptions": {",
""outDir": "../dist/out-tsc",",
""declaration": true,",
""types": ["node"]",
""types": ["node"],",
""resolveJsonModule": true,",
""allowSyntheticDefaultImports": true",
"},",
""include": ["src/**/*.ts"],",
""exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ export async function anchorApplicationGenerator(tree: Tree, rawOptions: AnchorA
return json
})

updateJson(tree, join(project.root, 'tsconfig.lib.json'), (json) => {
json.compilerOptions = {
...json.compilerOptions,
resolveJsonModule: true,
allowSyntheticDefaultImports: true,
}
return json
})

await anchorTemplateGenerator(tree, {
projectName: options.name,
name: 'base',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ exports[`anchor-template generator should be able to generate two templates side
"no-log-ix-name = []",
"cpi = ["no-entrypoint"]",
"default = []",
"idl-build = ["anchor-lang/idl-build"]",
"[dependencies]",
"anchor-lang = "0.29.0"",
"anchor-lang = "0.30.0"",
],
"isBinary": false,
"path": "target/programs/counter-one/Cargo.toml",
Expand Down Expand Up @@ -157,8 +158,9 @@ exports[`anchor-template generator should be able to generate two templates side
"no-log-ix-name = []",
"cpi = ["no-entrypoint"]",
"default = []",
"idl-build = ["anchor-lang/idl-build"]",
"[dependencies]",
"anchor-lang = "0.29.0"",
"anchor-lang = "0.30.0"",
],
"isBinary": false,
"path": "target/programs/counter-two/Cargo.toml",
Expand Down Expand Up @@ -250,13 +252,18 @@ exports[`anchor-template generator should be able to generate two templates side
"counter-one-exports.ts": {
"content": [
"// Here we export some useful types and functions for interacting with the Anchor program.",
"import { AnchorProvider, Program } from '@coral-xyz/anchor';",
"import { Cluster, PublicKey } from '@solana/web3.js';",
"import CounterOneIDL from '../target/idl/counter_one.json';",
"import type { CounterOne } from '../target/types/counter_one';",
"import { IDL as CounterOneIDL } from '../target/types/counter_one';",
"// Re-export the generated IDL and type",
"export { CounterOne, CounterOneIDL };",
"// After updating your program ID (e.g. after running \`anchor keys sync\`) update the value below.",
"export const COUNTER_ONE_PROGRAM_ID = new PublicKey('GMSER7ttdzFvei8hUjFrCxv3PNKje2NrPwuNYS7m15dA')",
"// The programId is imported from the program IDL.",
"export const COUNTER_ONE_PROGRAM_ID = new PublicKey(CounterOneIDL.address)",
"// This is a helper function to get the CounterOne Anchor program.",
"export function getCounterOneProgram(provider: AnchorProvider) {",
"return new Program(CounterOneIDL as CounterOne, provider);",
"}",
"// This is a helper function to get the program ID for the CounterOne program depending on the cluster.",
"export function getCounterOneProgramId(cluster: Cluster) {",
"switch (cluster) {",
Expand All @@ -274,13 +281,18 @@ exports[`anchor-template generator should be able to generate two templates side
"counter-two-exports.ts": {
"content": [
"// Here we export some useful types and functions for interacting with the Anchor program.",
"import { AnchorProvider, Program } from '@coral-xyz/anchor';",
"import { Cluster, PublicKey } from '@solana/web3.js';",
"import CounterTwoIDL from '../target/idl/counter_two.json';",
"import type { CounterTwo } from '../target/types/counter_two';",
"import { IDL as CounterTwoIDL } from '../target/types/counter_two';",
"// Re-export the generated IDL and type",
"export { CounterTwo, CounterTwoIDL };",
"// After updating your program ID (e.g. after running \`anchor keys sync\`) update the value below.",
"export const COUNTER_TWO_PROGRAM_ID = new PublicKey('GMSER7ttdzFvei8hUjFrCxv3PNKje2NrPwuNYS7m15dA')",
"// The programId is imported from the program IDL.",
"export const COUNTER_TWO_PROGRAM_ID = new PublicKey(CounterTwoIDL.address)",
"// This is a helper function to get the CounterTwo Anchor program.",
"export function getCounterTwoProgram(provider: AnchorProvider) {",
"return new Program(CounterTwoIDL as CounterTwo, provider);",
"}",
"// This is a helper function to get the program ID for the CounterTwo program depending on the cluster.",
"export function getCounterTwoProgramId(cluster: Cluster) {",
"switch (cluster) {",
Expand Down Expand Up @@ -1209,8 +1221,9 @@ exports[`anchor-template generator should generate files for basic template 1`]
"no-log-ix-name = []",
"cpi = ["no-entrypoint"]",
"default = []",
"idl-build = ["anchor-lang/idl-build"]",
"[dependencies]",
"anchor-lang = "0.29.0"",
"anchor-lang = "0.30.0"",
],
"isBinary": false,
"path": "target/programs/basic/Cargo.toml",
Expand Down Expand Up @@ -1257,13 +1270,18 @@ exports[`anchor-template generator should generate files for basic template 1`]
"basic-exports.ts": {
"content": [
"// Here we export some useful types and functions for interacting with the Anchor program.",
"import { AnchorProvider, Program } from '@coral-xyz/anchor';",
"import { PublicKey } from '@solana/web3.js';",
"import type { Basic } from '../target/types/basic';",
"import { IDL as BasicIDL } from '../target/types/basic';",
"// Re-export the generated IDL and type",
"export { Basic, BasicIDL };",
"// After updating your program ID (e.g. after running \`anchor keys sync\`) update the value below.",
"export const programId = new PublicKey('GMSER7ttdzFvei8hUjFrCxv3PNKje2NrPwuNYS7m15dA')",
"// The programId is imported from the program IDL.",
"export const BASIC_PROGRAM_ID = new PublicKey(BasicIDL.address)",
"// This is a helper function to get the Basic Anchor program.",
"export function getBasicProgram(provider: AnchorProvider) {",
"return new Program(BasicIDL as Basic, provider);",
"}",
],
"isBinary": false,
"path": "target/src/basic-exports.ts",
Expand Down Expand Up @@ -1431,8 +1449,9 @@ exports[`anchor-template generator should generate files for counter template 1`
"no-log-ix-name = []",
"cpi = ["no-entrypoint"]",
"default = []",
"idl-build = ["anchor-lang/idl-build"]",
"[dependencies]",
"anchor-lang = "0.29.0"",
"anchor-lang = "0.30.0"",
],
"isBinary": false,
"path": "target/programs/counter/Cargo.toml",
Expand Down Expand Up @@ -1524,13 +1543,18 @@ exports[`anchor-template generator should generate files for counter template 1`
"counter-exports.ts": {
"content": [
"// Here we export some useful types and functions for interacting with the Anchor program.",
"import { AnchorProvider, Program } from '@coral-xyz/anchor';",
"import { Cluster, PublicKey } from '@solana/web3.js';",
"import CounterIDL from '../target/idl/counter.json';",
"import type { Counter } from '../target/types/counter';",
"import { IDL as CounterIDL } from '../target/types/counter';",
"// Re-export the generated IDL and type",
"export { Counter, CounterIDL };",
"// After updating your program ID (e.g. after running \`anchor keys sync\`) update the value below.",
"export const COUNTER_PROGRAM_ID = new PublicKey('GMSER7ttdzFvei8hUjFrCxv3PNKje2NrPwuNYS7m15dA')",
"// The programId is imported from the program IDL.",
"export const COUNTER_PROGRAM_ID = new PublicKey(CounterIDL.address)",
"// This is a helper function to get the Counter Anchor program.",
"export function getCounterProgram(provider: AnchorProvider) {",
"return new Program(CounterIDL as Counter, provider);",
"}",
"// This is a helper function to get the program ID for the Counter program depending on the cluster.",
"export function getCounterProgramId(cluster: Cluster) {",
"switch (cluster) {",
Expand Down
Loading

0 comments on commit fabb55b

Please sign in to comment.