forge-solana-sdk 2.2.5 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/README.md +179 -1
  2. package/dist/cli.js +123 -7
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/analytics.d.ts +2 -0
  5. package/dist/commands/analytics.d.ts.map +1 -0
  6. package/dist/commands/analytics.js +51 -0
  7. package/dist/commands/analytics.js.map +1 -0
  8. package/dist/commands/audit.d.ts +1 -1
  9. package/dist/commands/audit.d.ts.map +1 -1
  10. package/dist/commands/audit.js +60 -2
  11. package/dist/commands/audit.js.map +1 -1
  12. package/dist/commands/ci.d.ts +2 -0
  13. package/dist/commands/ci.d.ts.map +1 -0
  14. package/dist/commands/ci.js +107 -0
  15. package/dist/commands/ci.js.map +1 -0
  16. package/dist/commands/cost.d.ts +2 -0
  17. package/dist/commands/cost.d.ts.map +1 -0
  18. package/dist/commands/cost.js +53 -0
  19. package/dist/commands/cost.js.map +1 -0
  20. package/dist/commands/docs.d.ts +2 -0
  21. package/dist/commands/docs.d.ts.map +1 -0
  22. package/dist/commands/docs.js +85 -0
  23. package/dist/commands/docs.js.map +1 -0
  24. package/dist/commands/init.d.ts +2 -1
  25. package/dist/commands/init.d.ts.map +1 -1
  26. package/dist/commands/init.js +88 -1
  27. package/dist/commands/init.js.map +1 -1
  28. package/dist/commands/interactive.d.ts +2 -0
  29. package/dist/commands/interactive.d.ts.map +1 -0
  30. package/dist/commands/interactive.js +51 -0
  31. package/dist/commands/interactive.js.map +1 -0
  32. package/dist/commands/keypair.d.ts +2 -0
  33. package/dist/commands/keypair.d.ts.map +1 -0
  34. package/dist/commands/keypair.js +54 -0
  35. package/dist/commands/keypair.js.map +1 -0
  36. package/dist/commands/migrate.d.ts +2 -0
  37. package/dist/commands/migrate.d.ts.map +1 -0
  38. package/dist/commands/migrate.js +15 -0
  39. package/dist/commands/migrate.js.map +1 -0
  40. package/dist/commands/monitor.d.ts +2 -0
  41. package/dist/commands/monitor.d.ts.map +1 -0
  42. package/dist/commands/monitor.js +49 -0
  43. package/dist/commands/monitor.js.map +1 -0
  44. package/dist/commands/network.d.ts +2 -0
  45. package/dist/commands/network.d.ts.map +1 -0
  46. package/dist/commands/network.js +58 -0
  47. package/dist/commands/network.js.map +1 -0
  48. package/dist/commands/profile.d.ts +2 -0
  49. package/dist/commands/profile.d.ts.map +1 -0
  50. package/dist/commands/profile.js +41 -0
  51. package/dist/commands/profile.js.map +1 -0
  52. package/dist/commands/quality.d.ts +2 -0
  53. package/dist/commands/quality.d.ts.map +1 -0
  54. package/dist/commands/quality.js +58 -0
  55. package/dist/commands/quality.js.map +1 -0
  56. package/dist/commands/search.d.ts +2 -0
  57. package/dist/commands/search.d.ts.map +1 -0
  58. package/dist/commands/search.js +26 -0
  59. package/dist/commands/search.js.map +1 -0
  60. package/dist/commands/upgrade.d.ts +2 -0
  61. package/dist/commands/upgrade.d.ts.map +1 -0
  62. package/dist/commands/upgrade.js +136 -0
  63. package/dist/commands/upgrade.js.map +1 -0
  64. package/dist/cpi.d.ts +1 -1
  65. package/dist/cpi.d.ts.map +1 -1
  66. package/dist/cpi.js +14 -0
  67. package/dist/cpi.js.map +1 -1
  68. package/dist/templates/index.d.ts +16 -0
  69. package/dist/templates/index.d.ts.map +1 -0
  70. package/dist/templates/index.js +81 -0
  71. package/dist/templates/index.js.map +1 -0
  72. package/dist/templates/token-program.d.ts +3 -0
  73. package/dist/templates/token-program.d.ts.map +1 -0
  74. package/dist/templates/token-program.js +158 -0
  75. package/dist/templates/token-program.js.map +1 -0
  76. package/package.json +2 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-program.d.ts","sourceRoot":"","sources":["../../src/templates/token-program.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,wBAAgB,4BAA4B,CAAC,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,YAAY,EAAE,CA0JvG"}
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateTokenProgramTemplate = generateTokenProgramTemplate;
4
+ function generateTokenProgramTemplate(projectName, anchorVersion) {
5
+ const programName = projectName.replace(/-/g, '_');
6
+ return [
7
+ {
8
+ path: `programs/${projectName}/src/lib.rs`,
9
+ content: `use anchor_lang::prelude::*;
10
+ use anchor_spl::token_interface::{self, InterfaceAccount, Interface, Mint, TokenAccount, TokenInterface, MintTo, TransferChecked, Burn};
11
+
12
+ declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
13
+
14
+ #[program]
15
+ pub mod ${programName} {
16
+ use super::*;
17
+
18
+ pub fn initialize_mint(
19
+ ctx: Context<InitializeMint>,
20
+ decimals: u8,
21
+ mint_authority: Pubkey,
22
+ freeze_authority: Option<Pubkey>,
23
+ ) -> Result<()> {
24
+ msg!("Initializing mint with decimals: {}", decimals);
25
+ Ok(())
26
+ }
27
+
28
+ pub fn mint_tokens(ctx: Context<MintTokens>, amount: u64) -> Result<()> {
29
+ msg!("Minting {} tokens", amount);
30
+
31
+ token_interface::mint_to(
32
+ CpiContext::new_with_signer(
33
+ ctx.accounts.token_program.to_account_info(),
34
+ MintTo {
35
+ mint: ctx.accounts.mint.to_account_info(),
36
+ to: ctx.accounts.to.to_account_info(),
37
+ authority: ctx.accounts.mint_authority.to_account_info(),
38
+ },
39
+ &[&[b"mint_authority", &[ctx.bumps.mint_authority]]],
40
+ ),
41
+ amount,
42
+ )?;
43
+
44
+ Ok(())
45
+ }
46
+
47
+ pub fn transfer_tokens(ctx: Context<TransferTokens>, amount: u64) -> Result<()> {
48
+ msg!("Transferring {} tokens", amount);
49
+
50
+ let decimals = ctx.accounts.mint.decimals;
51
+ token_interface::transfer_checked(
52
+ CpiContext::new(
53
+ ctx.accounts.token_program.to_account_info(),
54
+ TransferChecked {
55
+ from: ctx.accounts.from.to_account_info(),
56
+ to: ctx.accounts.to.to_account_info(),
57
+ authority: ctx.accounts.authority.to_account_info(),
58
+ mint: ctx.accounts.mint.to_account_info(),
59
+ },
60
+ ),
61
+ amount,
62
+ decimals,
63
+ )?;
64
+
65
+ Ok(())
66
+ }
67
+
68
+ pub fn burn_tokens(ctx: Context<BurnTokens>, amount: u64) -> Result<()> {
69
+ msg!("Burning {} tokens", amount);
70
+
71
+ token_interface::burn(
72
+ CpiContext::new(
73
+ ctx.accounts.token_program.to_account_info(),
74
+ Burn {
75
+ mint: ctx.accounts.mint.to_account_info(),
76
+ from: ctx.accounts.from.to_account_info(),
77
+ authority: ctx.accounts.authority.to_account_info(),
78
+ },
79
+ ),
80
+ amount,
81
+ )?;
82
+
83
+ Ok(())
84
+ }
85
+ }
86
+
87
+ #[derive(Accounts)]
88
+ pub struct InitializeMint {
89
+ #[account(mut)]
90
+ pub mint: InterfaceAccount<'info, Mint>,
91
+ pub mint_authority: Signer<'info>,
92
+ pub token_program: Interface<'info, TokenInterface>,
93
+ pub system_program: Program<'info, System>,
94
+ }
95
+
96
+ #[derive(Accounts)]
97
+ pub struct MintTokens<'info> {
98
+ #[account(mut)]
99
+ pub mint: InterfaceAccount<'info, Mint>,
100
+ #[account(mut)]
101
+ pub to: InterfaceAccount<'info, TokenAccount>,
102
+ #[account(
103
+ seeds = [b"mint_authority"],
104
+ bump
105
+ )]
106
+ pub mint_authority: Signer<'info>,
107
+ pub token_program: Interface<'info, TokenInterface>,
108
+ }
109
+
110
+ #[derive(Accounts)]
111
+ pub struct TransferTokens<'info> {
112
+ #[account(mut)]
113
+ pub from: InterfaceAccount<'info, TokenAccount>,
114
+ #[account(mut)]
115
+ pub to: InterfaceAccount<'info, TokenAccount>,
116
+ pub mint: InterfaceAccount<'info, Mint>,
117
+ pub authority: Signer<'info>,
118
+ pub token_program: Interface<'info, TokenInterface>,
119
+ }
120
+
121
+ #[derive(Accounts)]
122
+ pub struct BurnTokens<'info> {
123
+ #[account(mut)]
124
+ pub mint: InterfaceAccount<'info, Mint>,
125
+ #[account(mut)]
126
+ pub from: InterfaceAccount<'info, TokenAccount>,
127
+ pub authority: Signer<'info>,
128
+ pub token_program: Interface<'info, TokenInterface>,
129
+ }
130
+ `
131
+ },
132
+ {
133
+ path: `programs/${projectName}/Cargo.toml`,
134
+ content: `[package]
135
+ name = "${projectName}"
136
+ version = "0.1.0"
137
+ edition = "2021"
138
+
139
+ [lib]
140
+ crate-type = ["cdylib", "lib"]
141
+ name = "${programName}"
142
+
143
+ [features]
144
+ no-entrypoint = []
145
+ no-idl = []
146
+ no-log-ix-name = []
147
+ cpi = ["no-entrypoint"]
148
+ idl-build = ["anchor-lang/idl-build", "anchor-spl/idl-build"]
149
+ default = []
150
+
151
+ [dependencies]
152
+ anchor-lang = "${anchorVersion}"
153
+ anchor-spl = "${anchorVersion}"
154
+ `
155
+ }
156
+ ];
157
+ }
158
+ //# sourceMappingURL=token-program.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-program.js","sourceRoot":"","sources":["../../src/templates/token-program.ts"],"names":[],"mappings":";;AAEA,oEA0JC;AA1JD,SAAgB,4BAA4B,CAAC,WAAmB,EAAE,aAAqB;IACrF,MAAM,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAEnD,OAAO;QACL;YACE,IAAI,EAAE,YAAY,WAAW,aAAa;YAC1C,OAAO,EAAE;;;;;;UAML,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmHpB;SACI;QACD;YACE,IAAI,EAAE,YAAY,WAAW,aAAa;YAC1C,OAAO,EAAE;UACL,WAAW;;;;;;UAMX,WAAW;;;;;;;;;;;iBAWJ,aAAa;gBACd,aAAa;CAC5B;SACI;KACF,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "forge-solana-sdk",
3
- "version": "2.2.5",
3
+ "version": "3.1.0",
4
4
  "description": "FORGE - Intent-driven app assembly on Solana",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -45,4 +45,4 @@
45
45
  "mocha": "^10.2.0",
46
46
  "@types/mocha": "^10.0.1"
47
47
  }
48
- }
48
+ }