codama-renderers-dart 0.4.1 → 0.4.2
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/dist/index.browser.cjs +334 -131
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +334 -131
- package/dist/index.browser.js.map +1 -1
- package/dist/index.node.cjs +334 -131
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +334 -131
- package/dist/index.node.js.map +1 -1
- package/dist/index.react-native.js +334 -131
- package/dist/index.react-native.js.map +1 -1
- package/dist/types/fragments/accountPage.d.ts.map +1 -1
- package/dist/types/fragments/instructionPage.d.ts +1 -1
- package/dist/types/fragments/instructionPage.d.ts.map +1 -1
- package/dist/types/fragments/pdaPage.d.ts.map +1 -1
- package/dist/types/fragments/programPage.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/wellKnownAddresses.d.ts +11 -0
- package/dist/types/utils/wellKnownAddresses.d.ts.map +1 -0
- package/dist/types/visitors/getRenderMapVisitor.d.ts.map +1 -1
- package/dist/types/visitors/getTypeManifestVisitor.d.ts +1 -1
- package/dist/types/visitors/getTypeManifestVisitor.d.ts.map +1 -1
- package/package.json +27 -31
- package/src/fragments/accountPage.ts +15 -7
- package/src/fragments/pdaPage.ts +21 -2
- package/src/visitors/getTypeManifestVisitor.ts +2 -3
- package/LICENSE +0 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accountPage.d.ts","sourceRoot":"","sources":["../../../src/fragments/accountPage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAuB,MAAM,eAAe,CAAC;AAItE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAQrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIvD;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,WAAW,EACjB,KAAK,EAAE,WAAW,GACjB,QAAQ,
|
|
1
|
+
{"version":3,"file":"accountPage.d.ts","sourceRoot":"","sources":["../../../src/fragments/accountPage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAuB,MAAM,eAAe,CAAC;AAItE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAQrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIvD;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,WAAW,EACjB,KAAK,EAAE,WAAW,GACjB,QAAQ,CA0LV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instructionPage.d.ts","sourceRoot":"","sources":["../../../src/fragments/instructionPage.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"instructionPage.d.ts","sourceRoot":"","sources":["../../../src/fragments/instructionPage.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,EAChB,MAAM,eAAe,CAAC;AAGvB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAQrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAKvD;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,eAAe,EACrB,KAAK,EAAE,WAAW,GACjB,QAAQ,CA4PV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pdaPage.d.ts","sourceRoot":"","sources":["../../../src/fragments/pdaPage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAOrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"pdaPage.d.ts","sourceRoot":"","sources":["../../../src/fragments/pdaPage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAOrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAKvD;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,WAAW,GACjB,QAAQ,CAmJV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"programPage.d.ts","sourceRoot":"","sources":["../../../src/fragments/programPage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAQrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"programPage.d.ts","sourceRoot":"","sources":["../../../src/fragments/programPage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAQrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIvD;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,WAAW,EACjB,KAAK,EAAE,WAAW,GACjB,QAAQ,CAgEV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps well-known Solana public keys to their canonical Dart constant names
|
|
3
|
+
* in `package:solana_kit_addresses`. When the renderer encounters a known
|
|
4
|
+
* address, it emits a re-export from that package instead of hardcoding the
|
|
5
|
+
* address string.
|
|
6
|
+
*
|
|
7
|
+
* The keys are the base-58 public key strings as they appear in IDL/Codama nodes.
|
|
8
|
+
* The values are the Dart constant names exported by `solana_kit_addresses`.
|
|
9
|
+
*/
|
|
10
|
+
export declare const WELL_KNOWN_ADDRESSES: ReadonlyMap<string, string>;
|
|
11
|
+
//# sourceMappingURL=wellKnownAddresses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wellKnownAddresses.d.ts","sourceRoot":"","sources":["../../../src/utils/wellKnownAddresses.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAsD3D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRenderMapVisitor.d.ts","sourceRoot":"","sources":["../../../src/visitors/getRenderMapVisitor.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,KAAK,SAAS,EAIf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,KAAK,OAAO,EASb,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,mBAAmB,EAAe,MAAM,qBAAqB,CAAC;AAa5E;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,UAAU,GAAG,aAAa,GAAG,aAAa,GAAG,iBAAiB,GAAG,iBAAiB,GAAG,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"getRenderMapVisitor.d.ts","sourceRoot":"","sources":["../../../src/visitors/getRenderMapVisitor.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,KAAK,SAAS,EAIf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,KAAK,OAAO,EASb,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,mBAAmB,EAAe,MAAM,qBAAqB,CAAC;AAa5E;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,UAAU,GAAG,aAAa,GAAG,aAAa,GAAG,iBAAiB,GAAG,iBAAiB,GAAG,SAAS,CAAC,CAwK9H"}
|
|
@@ -15,5 +15,5 @@ export declare function getTypeManifestVisitor(input: {
|
|
|
15
15
|
linkables: LinkableDictionary;
|
|
16
16
|
stack: NodeStack;
|
|
17
17
|
nonScalarEnums?: CamelCaseString[];
|
|
18
|
-
}): Visitor<TypeManifest, "accountNode" | "definedTypeNode" | "errorNode" | "instructionAccountNode" | "instructionArgumentNode" | "instructionByteDeltaNode" | "instructionNode" | "instructionRemainingAccountsNode" | "instructionStatusNode" | "pdaNode" | "programNode" | "pdaSeedValueNode" | "accountBumpValueNode" | "accountValueNode" | "argumentValueNode" | "conditionalValueNode" | "identityValueNode" | "payerValueNode" | "pdaValueNode" | "programIdValueNode" | "resolverValueNode" | "fixedCountNode" | "prefixedCountNode" | "remainderCountNode" | "constantDiscriminatorNode" | "fieldDiscriminatorNode" | "sizeDiscriminatorNode" | "accountLinkNode" | "definedTypeLinkNode" | "instructionAccountLinkNode" | "instructionArgumentLinkNode" | "instructionLinkNode" | "pdaLinkNode" | "programLinkNode" | "constantPdaSeedNode" | "variablePdaSeedNode" | "enumEmptyVariantTypeNode" | "enumStructVariantTypeNode" | "enumTupleVariantTypeNode" | "amountTypeNode" | "arrayTypeNode" | "booleanTypeNode" | "bytesTypeNode" | "dateTimeTypeNode" | "enumTypeNode" | "fixedSizeTypeNode" | "hiddenPrefixTypeNode" | "hiddenSuffixTypeNode" | "mapTypeNode" | "numberTypeNode" | "optionTypeNode" | "postOffsetTypeNode" | "preOffsetTypeNode" | "publicKeyTypeNode" | "remainderOptionTypeNode" | "sentinelTypeNode" | "setTypeNode" | "sizePrefixTypeNode" | "solAmountTypeNode" | "stringTypeNode" | "structTypeNode" | "tupleTypeNode" | "zeroableOptionTypeNode" | "structFieldTypeNode" | "mapEntryValueNode" | "arrayValueNode" | "booleanValueNode" | "bytesValueNode" | "constantValueNode" | "enumValueNode" | "mapValueNode" | "noneValueNode" | "numberValueNode" | "publicKeyValueNode" | "setValueNode" | "someValueNode" | "stringValueNode" | "structValueNode" | "tupleValueNode" | "structFieldValueNode" | "rootNode">;
|
|
18
|
+
}): Visitor<TypeManifest, "accountNode" | "constantNode" | "definedTypeNode" | "errorNode" | "eventNode" | "instructionAccountNode" | "instructionArgumentNode" | "instructionByteDeltaNode" | "instructionNode" | "instructionRemainingAccountsNode" | "instructionStatusNode" | "pdaNode" | "programNode" | "pdaSeedValueNode" | "accountBumpValueNode" | "accountValueNode" | "argumentValueNode" | "conditionalValueNode" | "identityValueNode" | "payerValueNode" | "pdaValueNode" | "programIdValueNode" | "resolverValueNode" | "fixedCountNode" | "prefixedCountNode" | "remainderCountNode" | "constantDiscriminatorNode" | "fieldDiscriminatorNode" | "sizeDiscriminatorNode" | "accountLinkNode" | "definedTypeLinkNode" | "instructionAccountLinkNode" | "instructionArgumentLinkNode" | "instructionLinkNode" | "pdaLinkNode" | "programLinkNode" | "constantPdaSeedNode" | "variablePdaSeedNode" | "enumEmptyVariantTypeNode" | "enumStructVariantTypeNode" | "enumTupleVariantTypeNode" | "amountTypeNode" | "arrayTypeNode" | "booleanTypeNode" | "bytesTypeNode" | "dateTimeTypeNode" | "enumTypeNode" | "fixedSizeTypeNode" | "hiddenPrefixTypeNode" | "hiddenSuffixTypeNode" | "mapTypeNode" | "numberTypeNode" | "optionTypeNode" | "postOffsetTypeNode" | "preOffsetTypeNode" | "publicKeyTypeNode" | "remainderOptionTypeNode" | "sentinelTypeNode" | "setTypeNode" | "sizePrefixTypeNode" | "solAmountTypeNode" | "stringTypeNode" | "structTypeNode" | "tupleTypeNode" | "zeroableOptionTypeNode" | "structFieldTypeNode" | "mapEntryValueNode" | "arrayValueNode" | "booleanValueNode" | "bytesValueNode" | "constantValueNode" | "enumValueNode" | "mapValueNode" | "noneValueNode" | "numberValueNode" | "publicKeyValueNode" | "setValueNode" | "someValueNode" | "stringValueNode" | "structValueNode" | "tupleValueNode" | "structFieldValueNode" | "rootNode">;
|
|
19
19
|
//# sourceMappingURL=getTypeManifestVisitor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTypeManifestVisitor.d.ts","sourceRoot":"","sources":["../../../src/visitors/getTypeManifestVisitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,eAAe,EA8BrB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,SAAS,EACd,KAAK,OAAO,EAIb,MAAM,uBAAuB,CAAC;AAI/B,OAAO,EAEL,KAAK,YAAY,EAKlB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,KAAK,WAAW,EAAa,MAAM,8BAA8B,CAAC;AAE3E;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAE5E;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE;IAC5C,OAAO,EAAE,WAAW,CAAC;IACrB,SAAS,EAAE,kBAAkB,CAAC;IAC9B,KAAK,EAAE,SAAS,CAAC;IACjB,cAAc,CAAC,EAAE,eAAe,EAAE,CAAC;CACpC,
|
|
1
|
+
{"version":3,"file":"getTypeManifestVisitor.d.ts","sourceRoot":"","sources":["../../../src/visitors/getTypeManifestVisitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,eAAe,EA8BrB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,SAAS,EACd,KAAK,OAAO,EAIb,MAAM,uBAAuB,CAAC;AAI/B,OAAO,EAEL,KAAK,YAAY,EAKlB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,KAAK,WAAW,EAAa,MAAM,8BAA8B,CAAC;AAE3E;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAE5E;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE;IAC5C,OAAO,EAAE,WAAW,CAAC;IACrB,SAAS,EAAE,kBAAkB,CAAC;IAC9B,KAAK,EAAE,SAAS,CAAC;IACjB,cAAc,CAAC,EAAE,eAAe,EAAE,CAAC;CACpC,6xDAymBA"}
|
package/package.json
CHANGED
|
@@ -1,23 +1,31 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
|
|
2
|
+
"dependencies": {
|
|
3
|
+
"@codama/errors": "^1.4.4",
|
|
4
|
+
"@codama/nodes": "^1.4.4",
|
|
5
|
+
"@codama/renderers-core": "^1.3.3",
|
|
6
|
+
"@codama/visitors-core": "^1.4.4"
|
|
7
|
+
},
|
|
4
8
|
"description": "Codama renderer for generating Dart code targeting the solana_kit SDK",
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"@codama/nodes-from-anchor": "^1.3.9",
|
|
11
|
+
"@codama/renderers-js": "^2.0.2",
|
|
12
|
+
"@vitest/coverage-v8": "4.1.0"
|
|
13
|
+
},
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=18"
|
|
16
|
+
},
|
|
5
17
|
"exports": {
|
|
6
|
-
"node": {
|
|
7
|
-
"import": "./dist/index.node.mjs",
|
|
8
|
-
"require": "./dist/index.node.cjs"
|
|
9
|
-
},
|
|
10
18
|
"browser": {
|
|
11
19
|
"import": "./dist/index.browser.mjs",
|
|
12
20
|
"require": "./dist/index.browser.cjs"
|
|
13
21
|
},
|
|
22
|
+
"node": {
|
|
23
|
+
"import": "./dist/index.node.mjs",
|
|
24
|
+
"require": "./dist/index.node.cjs"
|
|
25
|
+
},
|
|
14
26
|
"react-native": "./dist/index.react-native.mjs",
|
|
15
27
|
"types": "./dist/types/index.d.ts"
|
|
16
28
|
},
|
|
17
|
-
"main": "./dist/index.node.cjs",
|
|
18
|
-
"module": "./dist/index.node.mjs",
|
|
19
|
-
"types": "./dist/types/index.d.ts",
|
|
20
|
-
"type": "module",
|
|
21
29
|
"files": [
|
|
22
30
|
"dist",
|
|
23
31
|
"src"
|
|
@@ -30,28 +38,13 @@
|
|
|
30
38
|
"code-generator"
|
|
31
39
|
],
|
|
32
40
|
"license": "MIT",
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"directory": "packages/codama-renderers-dart"
|
|
37
|
-
},
|
|
38
|
-
"dependencies": {
|
|
39
|
-
"@codama/errors": "^1.4.4",
|
|
40
|
-
"@codama/nodes": "^1.4.4",
|
|
41
|
-
"@codama/renderers-core": "^1.3.3",
|
|
42
|
-
"@codama/visitors-core": "^1.4.4"
|
|
43
|
-
},
|
|
44
|
-
"devDependencies": {
|
|
45
|
-
"@codama/nodes-from-anchor": "^1.3.9",
|
|
46
|
-
"@codama/renderers-js": "^2.0.2",
|
|
47
|
-
"@vitest/coverage-v8": "3.2.4"
|
|
48
|
-
},
|
|
49
|
-
"engines": {
|
|
50
|
-
"node": ">=18"
|
|
51
|
-
},
|
|
41
|
+
"main": "./dist/index.node.cjs",
|
|
42
|
+
"module": "./dist/index.node.mjs",
|
|
43
|
+
"name": "codama-renderers-dart",
|
|
52
44
|
"publishConfig": {
|
|
53
45
|
"access": "public"
|
|
54
46
|
},
|
|
47
|
+
"repository": "https://github.com/openbudgetfun/solana_kit/tree/main/packages/codama-renderers-dart",
|
|
55
48
|
"scripts": {
|
|
56
49
|
"build": "pnpm exec rimraf dist && pnpm exec tsup && pnpm exec tsc -p tsconfig.declarations.json",
|
|
57
50
|
"lint": "eslint --ext .ts src",
|
|
@@ -59,5 +52,8 @@
|
|
|
59
52
|
"test:coverage": "pnpm exec vitest run --coverage.enabled --coverage.reporter=lcov",
|
|
60
53
|
"test:watch": "pnpm exec vitest",
|
|
61
54
|
"typecheck": "pnpm exec tsc --noEmit"
|
|
62
|
-
}
|
|
63
|
-
|
|
55
|
+
},
|
|
56
|
+
"type": "module",
|
|
57
|
+
"types": "./dist/types/index.d.ts",
|
|
58
|
+
"version": "0.4.2"
|
|
59
|
+
}
|
|
@@ -44,6 +44,11 @@ export function getAccountPageFragment(
|
|
|
44
44
|
.map((f: StructFieldTypeNode) => ` required this.${camelCase(f.name as string)},`)
|
|
45
45
|
.join("\n");
|
|
46
46
|
|
|
47
|
+
// Empty structs use a no-arg constructor; `const Foo({})` is invalid Dart.
|
|
48
|
+
const ctorSignature = fields.length === 0
|
|
49
|
+
? `const ${typeName}();`
|
|
50
|
+
: `const ${typeName}({\n${ctorParams}\n });`;
|
|
51
|
+
|
|
47
52
|
const eqChecks =
|
|
48
53
|
fields.length === 0
|
|
49
54
|
? "true"
|
|
@@ -54,9 +59,14 @@ export function getAccountPageFragment(
|
|
|
54
59
|
)
|
|
55
60
|
.join(" &&\n ");
|
|
56
61
|
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
62
|
+
const hashFieldNames = fields.map((f: StructFieldTypeNode) => camelCase(f.name as string));
|
|
63
|
+
// `Object.hash()` requires at least two arguments, so handle 0/1 fields specially.
|
|
64
|
+
const hashCodeExpr =
|
|
65
|
+
hashFieldNames.length === 0
|
|
66
|
+
? "0"
|
|
67
|
+
: hashFieldNames.length === 1
|
|
68
|
+
? `${hashFieldNames[0]}.hashCode`
|
|
69
|
+
: `Object.hash(${hashFieldNames.join(", ")})`;
|
|
60
70
|
|
|
61
71
|
const toStringFields = fields
|
|
62
72
|
.map(
|
|
@@ -129,9 +139,7 @@ ${use("decodeAccount", "solanaAccounts")}
|
|
|
129
139
|
|
|
130
140
|
@immutable
|
|
131
141
|
class ${fragmentFromString(typeName)} {
|
|
132
|
-
|
|
133
|
-
${fragmentFromString(ctorParams)}
|
|
134
|
-
});
|
|
142
|
+
${fragmentFromString(ctorSignature)}
|
|
135
143
|
|
|
136
144
|
${fragmentFromString(fieldDecls)}
|
|
137
145
|
|
|
@@ -143,7 +151,7 @@ ${fragmentFromString(fieldDecls)}
|
|
|
143
151
|
${fragmentFromString(eqChecks)};
|
|
144
152
|
|
|
145
153
|
@override
|
|
146
|
-
int get hashCode =>
|
|
154
|
+
int get hashCode => ${fragmentFromString(hashCodeExpr)};
|
|
147
155
|
|
|
148
156
|
@override
|
|
149
157
|
String toString() => '${fragmentFromString(typeName)}(${fragmentFromString(toStringFields)})';
|
package/src/fragments/pdaPage.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from "../utils/fragment.js";
|
|
11
11
|
import type { RenderScope } from "../utils/options.js";
|
|
12
12
|
import { camelCase, pascalCase } from "../utils/nameTransformers.js";
|
|
13
|
+
import type { TypeManifest } from "../utils/typeManifest.js";
|
|
13
14
|
import { WELL_KNOWN_ADDRESSES } from "../utils/wellKnownAddresses.js";
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -41,10 +42,14 @@ export function getPdaPageFragment(
|
|
|
41
42
|
// Build seeds class if there are variable seeds
|
|
42
43
|
const hasSeedsClass = variableSeeds.length > 0;
|
|
43
44
|
|
|
45
|
+
// Collect type manifests so their imports can be merged into the result.
|
|
46
|
+
const seedManifests: TypeManifest[] = [];
|
|
47
|
+
|
|
44
48
|
const seedFieldDecls = variableSeeds
|
|
45
49
|
.map((s) => {
|
|
46
50
|
if (s.kind !== "variablePdaSeedNode") return "";
|
|
47
51
|
const manifest = visit(s.type, scope.typeManifestVisitor);
|
|
52
|
+
seedManifests.push(manifest);
|
|
48
53
|
return ` final ${manifest.type.content} ${camelCase(s.name as string)};`;
|
|
49
54
|
})
|
|
50
55
|
.join("\n");
|
|
@@ -78,10 +83,12 @@ export function getPdaPageFragment(
|
|
|
78
83
|
}
|
|
79
84
|
} else if (seed.value.kind === "numberValueNode") {
|
|
80
85
|
const manifest = visit(seed.type, scope.typeManifestVisitor);
|
|
86
|
+
seedManifests.push(manifest);
|
|
81
87
|
seedValues.push(` ${manifest.encoder.content}.encode(${seed.value.number}),`);
|
|
82
88
|
}
|
|
83
89
|
} else if (seed.kind === "variablePdaSeedNode") {
|
|
84
90
|
const manifest = visit(seed.type, scope.typeManifestVisitor);
|
|
91
|
+
seedManifests.push(manifest);
|
|
85
92
|
seedValues.push(
|
|
86
93
|
` ${manifest.encoder.content}.encode(seeds.${camelCase(seed.name as string)}),`,
|
|
87
94
|
);
|
|
@@ -105,12 +112,15 @@ export function getPdaPageFragment(
|
|
|
105
112
|
? use("Uint8List", "dartTypedData")
|
|
106
113
|
: fragmentFromString("");
|
|
107
114
|
|
|
115
|
+
// `@immutable` is only needed when a seeds class is emitted.
|
|
116
|
+
const metaImport = hasSeedsClass ? use("immutable", "meta") : fragmentFromString("");
|
|
117
|
+
|
|
108
118
|
const parts: Fragment[] = [
|
|
109
119
|
fragment`// Auto-generated. Do not edit.
|
|
110
120
|
// ignore_for_file: type=lint
|
|
111
121
|
|
|
112
122
|
${typedDataImport}
|
|
113
|
-
${
|
|
123
|
+
${metaImport}
|
|
114
124
|
${use("Address", "solanaAddresses")}
|
|
115
125
|
${use("getAddressEncoder", "solanaAddresses")}
|
|
116
126
|
${use("getProgramDerivedAddress", "solanaAddresses")}`,
|
|
@@ -146,7 +156,16 @@ ${fragmentFromString(seedValues.join("\n"))}
|
|
|
146
156
|
);
|
|
147
157
|
}`);
|
|
148
158
|
|
|
149
|
-
|
|
159
|
+
const result = mergeFragments(parts, (cs) => cs.join("\n"));
|
|
160
|
+
|
|
161
|
+
// Merge seed type manifest imports (encoders/types) into the result so that
|
|
162
|
+
// helpers like `getU64Encoder` are imported.
|
|
163
|
+
for (const manifest of seedManifests) {
|
|
164
|
+
result.imports.mergeWith(manifest.encoder.imports);
|
|
165
|
+
result.imports.mergeWith(manifest.type.imports);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return result;
|
|
150
169
|
}
|
|
151
170
|
|
|
152
171
|
function bytesValueToDart(hex: string): string {
|
|
@@ -137,9 +137,8 @@ export function getTypeManifestVisitor(input: {
|
|
|
137
137
|
const codecName = getNumberCodecName(format);
|
|
138
138
|
|
|
139
139
|
return {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
: fragmentFromString(dartType),
|
|
140
|
+
// `BigInt` and other number types live in `dart:core` and need no import.
|
|
141
|
+
type: fragmentFromString(dartType),
|
|
143
142
|
encoder: fragment`${use(
|
|
144
143
|
`get${codecName}Encoder`,
|
|
145
144
|
"solanaCodecsNumbers",
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Ifiok Jr.
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|