@typesol/cli 0.48.0 → 0.49.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/CHANGELOG.md +159 -1
- package/NOTICE +8 -1
- package/README.md +103 -41
- package/SECURITY.md +5 -0
- package/dist/compiler/emit/base.d.ts +6 -4
- package/dist/compiler/emit/base.js +11 -5
- package/dist/compiler/emit/calls.js +41 -1
- package/dist/compiler/emit/expressions.js +3 -1
- package/dist/compiler/emit/program.js +4 -4
- package/dist/compiler/emit/storage.js +8 -3
- package/dist/compiler/hints.js +3 -0
- package/docker/deps/0.49.0.lock.json +1206 -0
- package/docs/architecture.md +2 -2
- package/docs/audit.md +30 -14
- package/docs/case-study-escrow.md +7 -5
- package/docs/case-study-marginfi.md +15 -2
- package/docs/case-study-multisig.md +2 -1
- package/docs/case-study-raydium-amm.md +2 -1
- package/docs/case-study-spl-stake-pool.md +4 -3
- package/docs/language-accounts.md +5 -6
- package/docs/language-builtins.md +3 -1
- package/docs/language-errors-events.md +1 -1
- package/docs/language-native.md +23 -3
- package/docs/language-statements.md +3 -2
- package/docs/language.md +2 -2
- package/docs/mainnet.md +1 -1
- package/docs/runtime.md +7 -0
- package/docs/security-model.md +11 -4
- package/docs/stability.md +9 -4
- package/docs/testing.md +16 -4
- package/docs/troubleshooting.md +1 -1
- package/lib/typesol.d.ts +19 -1
- package/llms-full.txt +62 -28
- package/llms.txt +2 -1
- package/package.json +3 -3
- package/releases/0.48.0.json +847 -0
- package/runtime/typesol_rt.h +2 -1
|
@@ -59,12 +59,12 @@ export function emitProgram(analysis, opts = {}) {
|
|
|
59
59
|
else if (panicFlag.value)
|
|
60
60
|
out.push(`#define TS_PANIC_ON_OVERFLOW 1`);
|
|
61
61
|
}
|
|
62
|
-
// `const PANIC_STYLE = "solana-1.14"`: panics log as solana_program
|
|
63
|
-
// emitter); PANIC_ON_OVERFLOW's panics abort too instead of calling sol_panic_.
|
|
62
|
+
// `const PANIC_STYLE = "solana-1.14"` / `"solana-1.18"`: panics log as that solana_program's panic handler does and
|
|
63
|
+
// abort (read by the emitter); PANIC_ON_OVERFLOW's panics abort too instead of calling sol_panic_.
|
|
64
64
|
const panicStyle = model.constants.get("PANIC_STYLE");
|
|
65
65
|
if (panicStyle) {
|
|
66
|
-
if (panicStyle.value !== "solana-1.14")
|
|
67
|
-
reporter.error(analysis.sourceFile,
|
|
66
|
+
if (panicStyle.value !== "solana-1.14" && panicStyle.value !== "solana-1.18")
|
|
67
|
+
reporter.error(analysis.sourceFile, 'PANIC_STYLE must be "solana-1.14" (panics log `panicked at \'<message>\', <file>:<line>:<col>` and abort, as programs built with solana-program 1.14 to 1.17 do) or "solana-1.18" (`panicked at <file>:<line>:<col>:` and the message on the next line, then abort, as solana-program 1.18\'s); leave it out for the default');
|
|
68
68
|
else if (panicFlag?.value === true)
|
|
69
69
|
out.push(`#define TS_PANIC_ABORT 1`);
|
|
70
70
|
}
|
|
@@ -901,9 +901,14 @@ export class StorageEmitter extends AliasEmitter {
|
|
|
901
901
|
const h = this.handle(node.expression);
|
|
902
902
|
if (h) {
|
|
903
903
|
// Remaining accounts carry no static guarantees: check writability where it is written, and that it is not
|
|
904
|
-
// also another (declared or remaining) account, which would let one balance be counted twice.
|
|
905
|
-
|
|
906
|
-
|
|
904
|
+
// also another (declared or remaining) account, which would let one balance be counted twice. Under
|
|
905
|
+
// NATIVE_ACCOUNT_WRITES the write is a native program's `**a.lamports.borrow_mut() = v`: an account passed twice
|
|
906
|
+
// shares one record (as Rust's duplicate AccountInfos share one RefCell), and the runtime judges writability
|
|
907
|
+
// when the instruction ends (ReadonlyLamportChange / UnbalancedInstruction).
|
|
908
|
+
if (!this.nativeAccountWrites()) {
|
|
909
|
+
this.line(`TS_TRY(ts_check_writable(${h}));`);
|
|
910
|
+
this.line(`TS_TRY(ts_check_unaliased(params, ${h}));`);
|
|
911
|
+
}
|
|
907
912
|
return { type: U64, read: `${h}->lamports`, write: (c) => `${h}->lamports = ${c}` };
|
|
908
913
|
}
|
|
909
914
|
}
|
package/dist/compiler/hints.js
CHANGED
|
@@ -91,6 +91,9 @@ export function hintForTypeScript(d, message, libPath) {
|
|
|
91
91
|
case 2365: // Operator '+=' cannot be applied to types 'bigint' and 'number'.
|
|
92
92
|
case 2322: // Type 'number' is not assignable to type 'bigint'.
|
|
93
93
|
case 2345: // Argument of type 'bigint' is not assignable to parameter of type 'number'.
|
|
94
|
+
// Argument of type 'TokenAccount' is not assignable to parameter of type 'RemainingAccount | AccountInfo'.
|
|
95
|
+
if (/parameter of type '(?:RemainingAccount \| AccountInfo|AccountInfo \| RemainingAccount)'/.test(message))
|
|
96
|
+
return "pass a remaining account (remainingAccounts().get(i)) or an AccountInfo parameter; a declared parameter of a program or sysvar type is used as it is";
|
|
94
97
|
if (/\bDate\.now\(|\bnew Date\b/.test(line))
|
|
95
98
|
return CLOCK_HINT;
|
|
96
99
|
if (/\bMath\.\w+\(/.test(line))
|