Skip to content

Commit e02e2ad

Browse files
authored
Fix JS rendering issues for instruction edge cases (#245)
1 parent aa6dcd1 commit e02e2ad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+10211
-10
lines changed

.changeset/smart-worms-ring.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@codama/renderers-js-umi': patch
3+
'@codama/renderers-rust': patch
4+
'@codama/renderers-js': patch
5+
---
6+
7+
Fix JS rendering issues for instruction edge cases
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module.exports = {
2+
extends: ['@solana/eslint-config-solana'],
3+
ignorePatterns: [
4+
'.eslintrc.cjs',
5+
'start.js',
6+
'tsup.config.ts',
7+
'env-shim.ts',
8+
],
9+
parserOptions: {
10+
project: 'tsconfig.json',
11+
tsconfigRootDir: __dirname,
12+
sourceType: 'module',
13+
},
14+
rules: {
15+
'@typescript-eslint/ban-types': 'off',
16+
'@typescript-eslint/sort-type-constituents': 'off',
17+
'prefer-destructuring': 'off',
18+
'simple-import-sort/imports': 'off',
19+
'sort-keys-fix/sort-keys-fix': 'off',
20+
'typescript-sort-keys/interface': 'off',
21+
},
22+
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"semi": true,
3+
"singleQuote": true,
4+
"trailingComma": "es5",
5+
"useTabs": false,
6+
"tabWidth": 2,
7+
"arrowParens": "always",
8+
"printWidth": 80
9+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Clever obfuscation to prevent the build system from inlining the value of `NODE_ENV`
2+
export const __DEV__ = /* @__PURE__ */ (() =>
3+
(process as any)['en' + 'v'].NODE_ENV === 'development')();
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
{
2+
"kind": "rootNode",
3+
"program": {
4+
"kind": "programNode",
5+
"pdas": [],
6+
"accounts": [],
7+
"instructions": [
8+
{
9+
"kind": "instructionNode",
10+
"name": "instruction1",
11+
"optionalAccountStrategy": "programId",
12+
"docs": ["Testing instructions with no accounts or arguments"],
13+
"accounts": [],
14+
"arguments": [],
15+
"remainingAccounts": []
16+
},
17+
{
18+
"kind": "instructionNode",
19+
"name": "instruction2",
20+
"optionalAccountStrategy": "programId",
21+
"docs": ["Testing instructions with remaining accounts only"],
22+
"accounts": [],
23+
"arguments": [],
24+
"remainingAccounts": [
25+
{
26+
"kind": "instructionRemainingAccountsNode",
27+
"value": {
28+
"kind": "argumentValueNode",
29+
"name": "remainingAccounts"
30+
},
31+
"isOptional": true,
32+
"isSigner": false
33+
}
34+
]
35+
},
36+
{
37+
"kind": "instructionNode",
38+
"name": "instruction3",
39+
"optionalAccountStrategy": "programId",
40+
"docs": ["Testing instructions with discriminator only"],
41+
"accounts": [],
42+
"arguments": [
43+
{
44+
"kind": "instructionArgumentNode",
45+
"name": "discriminator",
46+
"type": {
47+
"kind": "numberTypeNode",
48+
"format": "u32",
49+
"endian": "le"
50+
},
51+
"docs": [],
52+
"defaultValue": { "kind": "numberValueNode", "number": 42 },
53+
"defaultValueStrategy": "omitted"
54+
}
55+
],
56+
"discriminators": [
57+
{
58+
"kind": "fieldDiscriminatorNode",
59+
"name": "discriminator",
60+
"offset": 0
61+
}
62+
]
63+
},
64+
{
65+
"kind": "instructionNode",
66+
"name": "instruction4",
67+
"optionalAccountStrategy": "programId",
68+
"docs": ["Testing instructions with arguments only"],
69+
"accounts": [],
70+
"arguments": [
71+
{
72+
"kind": "instructionArgumentNode",
73+
"name": "myArgument",
74+
"type": {
75+
"kind": "numberTypeNode",
76+
"format": "u64",
77+
"endian": "le"
78+
},
79+
"docs": []
80+
}
81+
]
82+
},
83+
{
84+
"kind": "instructionNode",
85+
"name": "instruction5",
86+
"optionalAccountStrategy": "programId",
87+
"docs": ["Testing instructions with optional arguments only"],
88+
"accounts": [],
89+
"arguments": [
90+
{
91+
"kind": "instructionArgumentNode",
92+
"name": "myArgument",
93+
"type": {
94+
"kind": "numberTypeNode",
95+
"format": "u64",
96+
"endian": "le"
97+
},
98+
"defaultValue": { "kind": "numberValueNode", "number": 42 },
99+
"docs": []
100+
}
101+
]
102+
},
103+
{
104+
"kind": "instructionNode",
105+
"name": "instruction6",
106+
"optionalAccountStrategy": "programId",
107+
"docs": ["Testing instructions with accounts only"],
108+
"accounts": [
109+
{
110+
"kind": "instructionAccountNode",
111+
"name": "myAccount",
112+
"isWritable": true,
113+
"isSigner": false,
114+
"isOptional": false,
115+
"docs": []
116+
}
117+
],
118+
"arguments": []
119+
},
120+
{
121+
"kind": "instructionNode",
122+
"name": "instruction7",
123+
"optionalAccountStrategy": "programId",
124+
"docs": ["Testing instructions with optional accounts only"],
125+
"accounts": [
126+
{
127+
"kind": "instructionAccountNode",
128+
"name": "myAccount",
129+
"isWritable": true,
130+
"isSigner": false,
131+
"isOptional": true,
132+
"docs": []
133+
}
134+
],
135+
"arguments": []
136+
}
137+
],
138+
"definedTypes": [],
139+
"errors": [],
140+
"name": "dummy",
141+
"prefix": "",
142+
"publicKey": "Dummy1111111111111111111111111111111111",
143+
"version": "3.0.1",
144+
"origin": "shank"
145+
},
146+
"additionalPrograms": [],
147+
"standard": "codama",
148+
"version": "1.0.0"
149+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"name": "@codama/renderers-js-umi-e2e-dummy",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "commonjs",
6+
"sideEffects": false,
7+
"scripts": {
8+
"build": "rimraf dist && tsup && tsc -p ./tsconfig.declarations.json",
9+
"test": "ava",
10+
"lint": "eslint --ext js,ts,tsx src && prettier --check src test",
11+
"lint:fix": "eslint --fix --ext js,ts,tsx src && prettier --write src test"
12+
},
13+
"publishConfig": {
14+
"access": "public",
15+
"registry": "https://registry.npmjs.org"
16+
},
17+
"license": "MIT",
18+
"peerDependencies": {
19+
"@metaplex-foundation/umi": "^0.9.0"
20+
},
21+
"devDependencies": {
22+
"@ava/typescript": "^4.1.0",
23+
"@metaplex-foundation/umi": "^0.9.0",
24+
"@metaplex-foundation/umi-bundle-tests": "^0.9.0",
25+
"@solana/eslint-config-solana": "^3.0.0",
26+
"@solana/web3.js": "1.91.7",
27+
"@typescript-eslint/eslint-plugin": "^7.3.1",
28+
"@typescript-eslint/parser": "^7.3.1",
29+
"ava": "^6.1.2",
30+
"eslint": "^8.57.0",
31+
"prettier": "^3.2.5",
32+
"rimraf": "^5.0.5",
33+
"tsup": "^8.0.2",
34+
"typedoc": "^0.25.12",
35+
"typedoc-plugin-missing-exports": "^2.2.0",
36+
"typescript": "^5.4.2"
37+
},
38+
"ava": {
39+
"typescript": {
40+
"compile": false,
41+
"rewritePaths": {
42+
"test/": "dist/test/"
43+
}
44+
}
45+
},
46+
"packageManager": "[email protected]"
47+
}

0 commit comments

Comments
 (0)