@codama/renderers-rust 1.2.9 → 2.0.1
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 +15 -13
- package/dist/index.node.cjs +288 -34
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +290 -37
- package/dist/index.node.mjs.map +1 -1
- package/dist/templates/accountsPage.njk +3 -3
- package/dist/types/ImportMap.d.ts +4 -1
- package/dist/types/ImportMap.d.ts.map +1 -1
- package/dist/types/getRenderMapVisitor.d.ts +3 -4
- package/dist/types/getRenderMapVisitor.d.ts.map +1 -1
- package/dist/types/renderVisitor.d.ts +3 -2
- package/dist/types/renderVisitor.d.ts.map +1 -1
- package/dist/types/utils/cargoToml.d.ts +51 -0
- package/dist/types/utils/cargoToml.d.ts.map +1 -0
- package/dist/types/utils/fragment.d.ts +6 -0
- package/dist/types/utils/fragment.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/index.d.ts.map +1 -1
- package/package.json +12 -9
|
@@ -145,12 +145,12 @@ pub fn fetch_all_{{ account.name | snakeCase }}(
|
|
|
145
145
|
addresses: &[solana_pubkey::Pubkey],
|
|
146
146
|
) -> Result<Vec<crate::shared::DecodedAccount<{{ account.name | pascalCase }}>>, std::io::Error> {
|
|
147
147
|
let accounts = rpc.get_multiple_accounts(addresses)
|
|
148
|
-
.map_err(|e| std::io::Error::
|
|
148
|
+
.map_err(|e| std::io::Error::other(e.to_string()))?;
|
|
149
149
|
let mut decoded_accounts: Vec<crate::shared::DecodedAccount<{{ account.name | pascalCase }}>> = Vec::new();
|
|
150
150
|
for i in 0..addresses.len() {
|
|
151
151
|
let address = addresses[i];
|
|
152
152
|
let account = accounts[i].as_ref()
|
|
153
|
-
.ok_or(std::io::Error::
|
|
153
|
+
.ok_or(std::io::Error::other(format!("Account not found: {address}")))?;
|
|
154
154
|
let data = {{ account.name | pascalCase }}::from_bytes(&account.data)?;
|
|
155
155
|
decoded_accounts.push(crate::shared::DecodedAccount { address, account: account.clone(), data });
|
|
156
156
|
}
|
|
@@ -172,7 +172,7 @@ pub fn fetch_all_maybe_{{ account.name | snakeCase }}(
|
|
|
172
172
|
addresses: &[solana_pubkey::Pubkey],
|
|
173
173
|
) -> Result<Vec<crate::shared::MaybeAccount<{{ account.name | pascalCase }}>>, std::io::Error> {
|
|
174
174
|
let accounts = rpc.get_multiple_accounts(addresses)
|
|
175
|
-
.map_err(|e| std::io::Error::
|
|
175
|
+
.map_err(|e| std::io::Error::other(e.to_string()))?;
|
|
176
176
|
let mut decoded_accounts: Vec<crate::shared::MaybeAccount<{{ account.name | pascalCase }}>> = Vec::new();
|
|
177
177
|
for i in 0..addresses.len() {
|
|
178
178
|
let address = addresses[i];
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { TypeManifest } from './getTypeManifestVisitor';
|
|
1
|
+
import type { TypeManifest } from './getTypeManifestVisitor';
|
|
2
|
+
/** Rust keywords that should not be identified as crate names. */
|
|
3
|
+
export declare const RUST_CORE_IMPORTS: Set<string>;
|
|
2
4
|
export declare class ImportMap {
|
|
3
5
|
protected readonly _imports: Set<string>;
|
|
4
6
|
protected readonly _aliases: Map<string, string>;
|
|
@@ -11,6 +13,7 @@ export declare class ImportMap {
|
|
|
11
13
|
addAlias(importName: string, alias: string): ImportMap;
|
|
12
14
|
isEmpty(): boolean;
|
|
13
15
|
resolveDependencyMap(dependencies: Record<string, string>): ImportMap;
|
|
16
|
+
getExternalDependencies(dependencyMap: Record<string, string>): Set<string>;
|
|
14
17
|
toString(dependencies: Record<string, string>): string;
|
|
15
18
|
}
|
|
16
19
|
//# sourceMappingURL=ImportMap.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImportMap.d.ts","sourceRoot":"","sources":["../../src/ImportMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"Import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oDependencies, Fragment, LinkOverrides, TraitOptions } from './utils';
|
|
2
2
|
export type GetRenderMapOptions = {
|
|
3
3
|
anchorTraits?: boolean;
|
|
4
4
|
defaultTraitOverrides?: string[];
|
|
5
5
|
dependencyMap?: Record<string, string>;
|
|
6
|
+
dependencyVersions?: CargoDependencies;
|
|
6
7
|
linkOverrides?: LinkOverrides;
|
|
7
8
|
renderParentInstructions?: boolean;
|
|
8
9
|
traitOptions?: TraitOptions;
|
|
9
10
|
};
|
|
10
|
-
export declare function getRenderMapVisitor(options?: GetRenderMapOptions): import("@codama/visitors-core").Visitor<import("@codama/renderers-core").RenderMap<
|
|
11
|
-
content: string;
|
|
12
|
-
}>>, "accountNode" | "definedTypeNode" | "instructionNode" | "programNode" | "rootNode">;
|
|
11
|
+
export declare function getRenderMapVisitor(options?: GetRenderMapOptions): import("@codama/visitors-core").Visitor<import("@codama/renderers-core").RenderMap<Fragment>, "accountNode" | "definedTypeNode" | "instructionNode" | "programNode" | "rootNode">;
|
|
13
12
|
//# sourceMappingURL=getRenderMapVisitor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRenderMapVisitor.d.ts","sourceRoot":"","sources":["../../src/getRenderMapVisitor.ts"],"names":[],"mappings":"AA+BA,OAAO,
|
|
1
|
+
{"version":3,"file":"getRenderMapVisitor.d.ts","sourceRoot":"","sources":["../../src/getRenderMapVisitor.ts"],"names":[],"mappings":"AA+BA,OAAO,EACH,iBAAiB,EACjB,QAAQ,EAIR,aAAa,EAEb,YAAY,EACf,MAAM,SAAS,CAAC;AAEjB,MAAM,MAAM,mBAAmB,GAAG;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,kBAAkB,CAAC,EAAE,iBAAiB,CAAC;IACvC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,YAAY,CAAC,EAAE,YAAY,CAAC;CAC/B,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,mBAAwB,qLAgSpE"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { GetRenderMapOptions } from './getRenderMapVisitor';
|
|
2
2
|
export type RenderOptions = GetRenderMapOptions & {
|
|
3
|
-
crateFolder?: string;
|
|
4
3
|
deleteFolderBeforeRendering?: boolean;
|
|
5
4
|
formatCode?: boolean;
|
|
5
|
+
generatedFolder?: string;
|
|
6
|
+
syncCargoToml?: boolean;
|
|
6
7
|
toolchain?: string;
|
|
7
8
|
};
|
|
8
|
-
export declare function renderVisitor(
|
|
9
|
+
export declare function renderVisitor(crateFolder: string, options?: RenderOptions): import("@codama/visitors-core").Visitor<void, "rootNode">;
|
|
9
10
|
//# sourceMappingURL=renderVisitor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderVisitor.d.ts","sourceRoot":"","sources":["../../src/renderVisitor.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,mBAAmB,EAAuB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"renderVisitor.d.ts","sourceRoot":"","sources":["../../src/renderVisitor.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,mBAAmB,EAAuB,MAAM,uBAAuB,CAAC;AAGjF,MAAM,MAAM,aAAa,GAAG,mBAAmB,GAAG;IAC9C,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,6DAyB7E"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { RenderMap } from '@codama/renderers-core';
|
|
2
|
+
import type { RenderOptions } from '../renderVisitor';
|
|
3
|
+
import type { Fragment } from './fragment';
|
|
4
|
+
type CargoToml = CargoDependencyGroups & {
|
|
5
|
+
description?: string;
|
|
6
|
+
edition?: string | {
|
|
7
|
+
workspace: true;
|
|
8
|
+
};
|
|
9
|
+
features?: Record<string, string[]>;
|
|
10
|
+
license?: string | {
|
|
11
|
+
workspace: true;
|
|
12
|
+
};
|
|
13
|
+
name?: string;
|
|
14
|
+
repository?: string | {
|
|
15
|
+
workspace: true;
|
|
16
|
+
};
|
|
17
|
+
target?: Record<string, CargoDependencyGroups>;
|
|
18
|
+
version?: string;
|
|
19
|
+
workspace?: {
|
|
20
|
+
dependencies?: CargoDependencies;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
type CargoDependencyGroups = {
|
|
24
|
+
'build-dependencies'?: CargoDependencies;
|
|
25
|
+
dependencies?: CargoDependencies;
|
|
26
|
+
'dev-dependencies'?: CargoDependencies;
|
|
27
|
+
};
|
|
28
|
+
export type CargoDependencies = Record<string, CargoDependency>;
|
|
29
|
+
type CargoDependency = CargoDependencyObject | string;
|
|
30
|
+
type CargoDependencyObject = {
|
|
31
|
+
branch?: string;
|
|
32
|
+
'default-features'?: boolean;
|
|
33
|
+
features?: string[];
|
|
34
|
+
git?: string;
|
|
35
|
+
optional?: boolean;
|
|
36
|
+
package?: string;
|
|
37
|
+
path?: string;
|
|
38
|
+
tag?: string;
|
|
39
|
+
version?: string;
|
|
40
|
+
workspace?: boolean;
|
|
41
|
+
};
|
|
42
|
+
export declare const DEFAULT_DEPENDENCY_VERSIONS: CargoDependencies;
|
|
43
|
+
export declare function syncCargoToml(renderMap: RenderMap<Fragment>, crateFolder: string, options: Pick<RenderOptions, 'dependencyMap' | 'dependencyVersions' | 'syncCargoToml'>): void;
|
|
44
|
+
export declare function createNewCargoToml(usedDependencies: CargoDependencies): CargoToml;
|
|
45
|
+
export declare function updateExistingCargoToml(cargoToml: CargoToml, usedDependencies: CargoDependencies): CargoToml;
|
|
46
|
+
export declare function checkExistingCargoToml(cargoToml: CargoToml, usedDependencies: CargoDependencies): void;
|
|
47
|
+
export declare function getUsedDependencyVersions(renderMap: RenderMap<Fragment>, dependencyMap: Record<string, string>, dependencyVersions: CargoDependencies): CargoDependencies;
|
|
48
|
+
export declare function shouldUpdateDependency(dependency: string, currentDependency: CargoDependency, requiredDependency: CargoDependency): boolean;
|
|
49
|
+
export declare function shouldUpdateRange(dependency: string, currentRange: string, requiredRange: string): boolean;
|
|
50
|
+
export {};
|
|
51
|
+
//# sourceMappingURL=cargoToml.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cargoToml.d.ts","sourceRoot":"","sources":["../../../src/utils/cargoToml.ts"],"names":[],"mappings":"AACA,OAAO,EAAkC,SAAS,EAAa,MAAM,wBAAwB,CAAC;AAK9F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,KAAK,SAAS,GAAG,qBAAqB,GAAG;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,GAAG;QAAE,SAAS,EAAE,IAAI,CAAA;KAAE,CAAC;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACpC,OAAO,CAAC,EAAE,MAAM,GAAG;QAAE,SAAS,EAAE,IAAI,CAAA;KAAE,CAAC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,GAAG;QAAE,SAAS,EAAE,IAAI,CAAA;KAAE,CAAC;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS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AAE,iBAAiB,GAAG,IAAI,CA6CtG;AAED,wBAAgB,yBAAyB,CACrC,SAAS,EAAE,SAAS,CAAC,QAAQ,CAAC,EAC9B,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACrC,kBAAkB,EAAE,iBAAiB,GACtC,iBAAiB,CA4BnB;AAqBD,wBAAgB,sBAAsB,CAClC,UAAU,EAAE,MAAM,EAClB,iBAAiB,EAAE,eAAe,EAClC,kBAAkB,EAAE,eAAe,GACpC,OAAO,CAIT;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAiC1G"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fragment.d.ts","sourceRoot":"","sources":["../../../src/utils/fragment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,MAAM,QAAQ,GAAG,YAAY,GAAG;IAClC,OAAO,EAAE,SAAS,CAAC;CACtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,yBAAyB,CAAC;AACxC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codama/renderers-rust",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Renders Rust clients for your programs",
|
|
5
5
|
"exports": {
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -28,21 +28,24 @@
|
|
|
28
28
|
"client"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@codama/errors": "^1.
|
|
32
|
-
"@codama/nodes": "^1.
|
|
33
|
-
"@codama/renderers-core": "^1.3.
|
|
34
|
-
"@codama/visitors-core": "^1.
|
|
35
|
-
"@
|
|
36
|
-
"
|
|
31
|
+
"@codama/errors": "^1.5.0",
|
|
32
|
+
"@codama/nodes": "^1.5.0",
|
|
33
|
+
"@codama/renderers-core": "^1.3.5",
|
|
34
|
+
"@codama/visitors-core": "^1.5.0",
|
|
35
|
+
"@iarna/toml": "^2.2.5",
|
|
36
|
+
"@solana/codecs-strings": "^6.0.0",
|
|
37
|
+
"nunjucks": "^3.2.4",
|
|
38
|
+
"semver": "^7.7.3"
|
|
37
39
|
},
|
|
38
40
|
"devDependencies": {
|
|
39
|
-
"@codama/nodes-from-anchor": "^1.3.6",
|
|
40
41
|
"@changesets/changelog-github": "^0.5.1",
|
|
41
42
|
"@changesets/cli": "^2.29.7",
|
|
43
|
+
"@codama/nodes-from-anchor": "^1.3.6",
|
|
42
44
|
"@solana/eslint-config-solana": "^5.0.0",
|
|
43
45
|
"@solana/prettier-config-solana": "0.0.5",
|
|
44
|
-
"@types/node": "^
|
|
46
|
+
"@types/node": "^25",
|
|
45
47
|
"@types/nunjucks": "^3.2.6",
|
|
48
|
+
"@types/semver": "^7.7.1",
|
|
46
49
|
"agadoo": "^3.0.0",
|
|
47
50
|
"eslint": "^9.35.0",
|
|
48
51
|
"happy-dom": "^20.0.0",
|