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.
- package/README.md +179 -1
- package/dist/cli.js +123 -7
- package/dist/cli.js.map +1 -1
- package/dist/commands/analytics.d.ts +2 -0
- package/dist/commands/analytics.d.ts.map +1 -0
- package/dist/commands/analytics.js +51 -0
- package/dist/commands/analytics.js.map +1 -0
- package/dist/commands/audit.d.ts +1 -1
- package/dist/commands/audit.d.ts.map +1 -1
- package/dist/commands/audit.js +60 -2
- package/dist/commands/audit.js.map +1 -1
- package/dist/commands/ci.d.ts +2 -0
- package/dist/commands/ci.d.ts.map +1 -0
- package/dist/commands/ci.js +107 -0
- package/dist/commands/ci.js.map +1 -0
- package/dist/commands/cost.d.ts +2 -0
- package/dist/commands/cost.d.ts.map +1 -0
- package/dist/commands/cost.js +53 -0
- package/dist/commands/cost.js.map +1 -0
- package/dist/commands/docs.d.ts +2 -0
- package/dist/commands/docs.d.ts.map +1 -0
- package/dist/commands/docs.js +85 -0
- package/dist/commands/docs.js.map +1 -0
- package/dist/commands/init.d.ts +2 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +88 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/interactive.d.ts +2 -0
- package/dist/commands/interactive.d.ts.map +1 -0
- package/dist/commands/interactive.js +51 -0
- package/dist/commands/interactive.js.map +1 -0
- package/dist/commands/keypair.d.ts +2 -0
- package/dist/commands/keypair.d.ts.map +1 -0
- package/dist/commands/keypair.js +54 -0
- package/dist/commands/keypair.js.map +1 -0
- package/dist/commands/migrate.d.ts +2 -0
- package/dist/commands/migrate.d.ts.map +1 -0
- package/dist/commands/migrate.js +15 -0
- package/dist/commands/migrate.js.map +1 -0
- package/dist/commands/monitor.d.ts +2 -0
- package/dist/commands/monitor.d.ts.map +1 -0
- package/dist/commands/monitor.js +49 -0
- package/dist/commands/monitor.js.map +1 -0
- package/dist/commands/network.d.ts +2 -0
- package/dist/commands/network.d.ts.map +1 -0
- package/dist/commands/network.js +58 -0
- package/dist/commands/network.js.map +1 -0
- package/dist/commands/profile.d.ts +2 -0
- package/dist/commands/profile.d.ts.map +1 -0
- package/dist/commands/profile.js +41 -0
- package/dist/commands/profile.js.map +1 -0
- package/dist/commands/quality.d.ts +2 -0
- package/dist/commands/quality.d.ts.map +1 -0
- package/dist/commands/quality.js +58 -0
- package/dist/commands/quality.js.map +1 -0
- package/dist/commands/search.d.ts +2 -0
- package/dist/commands/search.d.ts.map +1 -0
- package/dist/commands/search.js +26 -0
- package/dist/commands/search.js.map +1 -0
- package/dist/commands/upgrade.d.ts +2 -0
- package/dist/commands/upgrade.d.ts.map +1 -0
- package/dist/commands/upgrade.js +136 -0
- package/dist/commands/upgrade.js.map +1 -0
- package/dist/cpi.d.ts +1 -1
- package/dist/cpi.d.ts.map +1 -1
- package/dist/cpi.js +14 -0
- package/dist/cpi.js.map +1 -1
- package/dist/templates/index.d.ts +16 -0
- package/dist/templates/index.d.ts.map +1 -0
- package/dist/templates/index.js +81 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/token-program.d.ts +3 -0
- package/dist/templates/token-program.d.ts.map +1 -0
- package/dist/templates/token-program.js +158 -0
- package/dist/templates/token-program.js.map +1 -0
- 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": "
|
|
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
|
+
}
|