everything-dev 1.27.0 → 1.28.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/dist/cli/infra.cjs +1 -1
- package/dist/cli/infra.mjs +1 -1
- package/dist/cli/init.cjs +7 -9
- package/dist/cli/init.cjs.map +1 -1
- package/dist/cli/init.d.cts +1 -1
- package/dist/cli/init.d.cts.map +1 -1
- package/dist/cli/init.d.mts +1 -1
- package/dist/cli/init.d.mts.map +1 -1
- package/dist/cli/init.mjs +7 -9
- package/dist/cli/init.mjs.map +1 -1
- package/dist/cli/prompts.cjs +28 -24
- package/dist/cli/prompts.cjs.map +1 -1
- package/dist/cli/prompts.mjs +27 -24
- package/dist/cli/prompts.mjs.map +1 -1
- package/dist/cli/sync.cjs +4 -1
- package/dist/cli/sync.cjs.map +1 -1
- package/dist/cli/sync.mjs +4 -1
- package/dist/cli/sync.mjs.map +1 -1
- package/dist/cli.cjs +187 -12
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +186 -11
- package/dist/cli.mjs.map +1 -1
- package/dist/contract.cjs +1 -1
- package/dist/contract.cjs.map +1 -1
- package/dist/contract.d.cts +38 -34
- package/dist/contract.d.cts.map +1 -1
- package/dist/contract.d.mts +38 -34
- package/dist/contract.d.mts.map +1 -1
- package/dist/contract.mjs +1 -0
- package/dist/contract.mjs.map +1 -1
- package/dist/dev-session.cjs +0 -1
- package/dist/dev-session.mjs +1 -1
- package/dist/index.cjs +0 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +0 -1
- package/dist/near-cli.cjs +1 -1
- package/dist/near-cli.mjs +1 -1
- package/dist/orchestrator.cjs +1 -1
- package/dist/orchestrator.mjs +1 -1
- package/dist/plugin.cjs +163 -139
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +67 -34
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts +66 -34
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +153 -130
- package/dist/plugin.mjs.map +1 -1
- package/dist/service-descriptor.d.cts +34 -0
- package/dist/service-descriptor.d.cts.map +1 -0
- package/dist/service-descriptor.d.mts +36 -0
- package/dist/service-descriptor.d.mts.map +1 -0
- package/dist/types.d.cts +2 -2
- package/dist/types.d.mts +2 -2
- package/package.json +2 -2
- package/src/api-contract.ts +0 -623
- package/src/app.ts +0 -193
- package/src/cli/catalog.ts +0 -49
- package/src/cli/framework-version.ts +0 -61
- package/src/cli/help.ts +0 -13
- package/src/cli/infra.ts +0 -190
- package/src/cli/init.ts +0 -1145
- package/src/cli/parse.ts +0 -147
- package/src/cli/prompts.ts +0 -135
- package/src/cli/snapshot.ts +0 -46
- package/src/cli/status.ts +0 -99
- package/src/cli/sync.ts +0 -429
- package/src/cli/timing.ts +0 -63
- package/src/cli/upgrade.ts +0 -869
- package/src/cli.ts +0 -516
- package/src/components/dev-view.tsx +0 -352
- package/src/components/streaming-view.ts +0 -177
- package/src/config.ts +0 -893
- package/src/contract.meta.ts +0 -140
- package/src/contract.ts +0 -326
- package/src/dev-logs.ts +0 -92
- package/src/dev-session.ts +0 -283
- package/src/fastkv.ts +0 -181
- package/src/index.ts +0 -8
- package/src/integrity.ts +0 -138
- package/src/internal/manifest-normalizer.ts +0 -290
- package/src/merge.ts +0 -187
- package/src/mf.ts +0 -147
- package/src/near-cli.ts +0 -259
- package/src/network.ts +0 -3
- package/src/orchestrator.ts +0 -493
- package/src/plugin.ts +0 -1799
- package/src/sdk.ts +0 -14
- package/src/service-descriptor.ts +0 -281
- package/src/shared.ts +0 -249
- package/src/sidebar.ts +0 -140
- package/src/types.ts +0 -330
- package/src/ui/head.ts +0 -83
- package/src/ui/index.ts +0 -5
- package/src/ui/metadata.ts +0 -95
- package/src/ui/router.ts +0 -88
- package/src/ui/runtime.ts +0 -42
- package/src/ui/types.ts +0 -65
- package/src/utils/banner.ts +0 -21
- package/src/utils/linkify.ts +0 -11
- package/src/utils/path-match.ts +0 -16
- package/src/utils/run.ts +0 -31
- package/src/utils/save-config.ts +0 -20
- package/src/utils/theme.ts +0 -39
package/src/near-cli.ts
DELETED
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
import { generateKeyPairSync } from "node:crypto";
|
|
2
|
-
import { Effect } from "effect";
|
|
3
|
-
import { execa } from "execa";
|
|
4
|
-
|
|
5
|
-
export interface NearTransactionConfig {
|
|
6
|
-
account: string;
|
|
7
|
-
contract: string;
|
|
8
|
-
method: string;
|
|
9
|
-
argsBase64: string;
|
|
10
|
-
network?: "mainnet" | "testnet";
|
|
11
|
-
privateKey?: string;
|
|
12
|
-
gas?: string;
|
|
13
|
-
deposit?: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface NearTransactionResult {
|
|
17
|
-
success: boolean;
|
|
18
|
-
txHash?: string;
|
|
19
|
-
error?: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface NearKeyPair {
|
|
23
|
-
publicKey: string;
|
|
24
|
-
privateKey: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface FunctionCallAccessKeyConfig {
|
|
28
|
-
account: string;
|
|
29
|
-
contract: string;
|
|
30
|
-
allowance: string;
|
|
31
|
-
functionNames: string[];
|
|
32
|
-
network?: "mainnet" | "testnet";
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const NEAR_CLI_VERSION = "0.23.5";
|
|
36
|
-
const INSTALLER_URL = `https://github.com/near/near-cli-rs/releases/download/v${NEAR_CLI_VERSION}/near-cli-rs-installer.sh`;
|
|
37
|
-
const BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
38
|
-
|
|
39
|
-
export class NearCliNotFoundError extends Error {
|
|
40
|
-
readonly _tag = "NearCliNotFoundError";
|
|
41
|
-
constructor() {
|
|
42
|
-
super("NEAR CLI not found");
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export class NearCliInstallError extends Error {
|
|
47
|
-
readonly _tag = "NearCliInstallError";
|
|
48
|
-
constructor(message: string) {
|
|
49
|
-
super(`Failed to install NEAR CLI: ${message}`);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export class NearTransactionError extends Error {
|
|
54
|
-
readonly _tag = "NearTransactionError";
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function base64UrlToBytes(input: string): Uint8Array {
|
|
58
|
-
const normalized = input.replace(/-/g, "+").replace(/_/g, "/");
|
|
59
|
-
return new Uint8Array(Buffer.from(normalized, "base64"));
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function base58Encode(input: Uint8Array): string {
|
|
63
|
-
if (input.length === 0) return "";
|
|
64
|
-
|
|
65
|
-
const digits: number[] = [0];
|
|
66
|
-
for (const byte of input) {
|
|
67
|
-
let carry = byte;
|
|
68
|
-
for (let i = 0; i < digits.length; i++) {
|
|
69
|
-
carry += digits[i]! << 8;
|
|
70
|
-
digits[i] = carry % 58;
|
|
71
|
-
carry = Math.floor(carry / 58);
|
|
72
|
-
}
|
|
73
|
-
while (carry > 0) {
|
|
74
|
-
digits.push(carry % 58);
|
|
75
|
-
carry = Math.floor(carry / 58);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
let output = "";
|
|
80
|
-
for (const byte of input) {
|
|
81
|
-
if (byte === 0) output += BASE58_ALPHABET[0];
|
|
82
|
-
else break;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
for (let i = digits.length - 1; i >= 0; i--) {
|
|
86
|
-
output += BASE58_ALPHABET[digits[i]!]!;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return output;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export function generateNearKeyPair(): NearKeyPair {
|
|
93
|
-
const { publicKey, privateKey } = generateKeyPairSync("ed25519");
|
|
94
|
-
const publicJwk = publicKey.export({ format: "jwk" }) as JsonWebKey;
|
|
95
|
-
const privateJwk = privateKey.export({ format: "jwk" }) as JsonWebKey;
|
|
96
|
-
|
|
97
|
-
if (!publicJwk.x || !privateJwk.d) {
|
|
98
|
-
throw new Error("Failed to generate NEAR keypair");
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const publicBytes = base64UrlToBytes(publicJwk.x);
|
|
102
|
-
const privateSeed = base64UrlToBytes(privateJwk.d);
|
|
103
|
-
const secretBytes = new Uint8Array(privateSeed.length + publicBytes.length);
|
|
104
|
-
secretBytes.set(privateSeed, 0);
|
|
105
|
-
secretBytes.set(publicBytes, privateSeed.length);
|
|
106
|
-
|
|
107
|
-
return {
|
|
108
|
-
publicKey: `ed25519:${base58Encode(publicBytes)}`,
|
|
109
|
-
privateKey: `ed25519:${base58Encode(secretBytes)}`,
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const checkNearCliInstalled = Effect.tryPromise({
|
|
114
|
-
try: async () => {
|
|
115
|
-
try {
|
|
116
|
-
await execa("near", ["--version"], { stdio: "pipe" });
|
|
117
|
-
return true;
|
|
118
|
-
} catch {
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
catch: () => new Error("Failed to check NEAR CLI"),
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
const installNearCli = Effect.tryPromise({
|
|
126
|
-
try: async () => {
|
|
127
|
-
await execa("sh", ["-c", `curl --proto '=https' --tlsv1.2 -LsSf ${INSTALLER_URL} | sh`], {
|
|
128
|
-
stdio: "inherit",
|
|
129
|
-
});
|
|
130
|
-
},
|
|
131
|
-
catch: (error) => {
|
|
132
|
-
if (error instanceof Error && "exitCode" in error) {
|
|
133
|
-
return new NearCliInstallError(
|
|
134
|
-
`Installer exited with code ${(error as { exitCode: number }).exitCode}`,
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
return new NearCliInstallError(error instanceof Error ? error.message : String(error));
|
|
138
|
-
},
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
async function runNearCommand(args: string[]): Promise<void> {
|
|
142
|
-
await execa("near", args, { stdio: "inherit" });
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export const ensureNearCli = Effect.gen(function* () {
|
|
146
|
-
const isInstalled = yield* checkNearCliInstalled;
|
|
147
|
-
if (isInstalled) return;
|
|
148
|
-
|
|
149
|
-
if (process.env.BOS_INSTALL_NEAR_CLI === "true") {
|
|
150
|
-
yield* installNearCli;
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
console.log();
|
|
155
|
-
console.log(" NEAR CLI not found");
|
|
156
|
-
|
|
157
|
-
console.log();
|
|
158
|
-
console.log(` To install manually: curl --proto '=https' --tlsv1.2 -LsSf ${INSTALLER_URL} | sh`);
|
|
159
|
-
console.log();
|
|
160
|
-
yield* Effect.fail(new NearCliNotFoundError());
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
export const executeTransaction = (
|
|
164
|
-
config: NearTransactionConfig,
|
|
165
|
-
): Effect.Effect<NearTransactionResult, Error> =>
|
|
166
|
-
Effect.gen(function* () {
|
|
167
|
-
const gas = (config.gas || "300Tgas").replace(/\s+/g, "");
|
|
168
|
-
const deposit = (config.deposit || "0NEAR").replace(/\s+/g, "");
|
|
169
|
-
const network = config.network || (config.account.endsWith(".testnet") ? "testnet" : "mainnet");
|
|
170
|
-
|
|
171
|
-
const args = [
|
|
172
|
-
"contract",
|
|
173
|
-
"call-function",
|
|
174
|
-
"as-transaction",
|
|
175
|
-
config.contract,
|
|
176
|
-
config.method,
|
|
177
|
-
"base64-args",
|
|
178
|
-
config.argsBase64,
|
|
179
|
-
"prepaid-gas",
|
|
180
|
-
gas,
|
|
181
|
-
"attached-deposit",
|
|
182
|
-
deposit,
|
|
183
|
-
"sign-as",
|
|
184
|
-
config.account,
|
|
185
|
-
"network-config",
|
|
186
|
-
network,
|
|
187
|
-
];
|
|
188
|
-
|
|
189
|
-
if (config.privateKey) {
|
|
190
|
-
args.push("sign-with-plaintext-private-key", config.privateKey, "send");
|
|
191
|
-
} else {
|
|
192
|
-
args.push("sign-with-keychain", "send");
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
const output = yield* Effect.tryPromise({
|
|
196
|
-
try: async () => {
|
|
197
|
-
const result = await execa("near", args, {
|
|
198
|
-
stdin: "inherit",
|
|
199
|
-
stdout: "pipe",
|
|
200
|
-
stderr: "pipe",
|
|
201
|
-
reject: false,
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
process.stdout.write(result.stdout);
|
|
205
|
-
const combined = `${result.stdout}\n${result.stderr}`;
|
|
206
|
-
const txHashMatch = combined.match(/Transaction ID:\s*([A-Za-z0-9]+)/i);
|
|
207
|
-
const hasCodeDoesNotExist = /CodeDoesNotExist/i.test(combined);
|
|
208
|
-
const hasTransactionFailed = /Transaction failed/i.test(combined);
|
|
209
|
-
const softSuccess =
|
|
210
|
-
Boolean(txHashMatch?.[1]) && hasCodeDoesNotExist && hasTransactionFailed;
|
|
211
|
-
|
|
212
|
-
if (result.exitCode === 0 || softSuccess) {
|
|
213
|
-
if (softSuccess) {
|
|
214
|
-
console.log(` ${txHashMatch?.[1]} — FastDATA CodeDoesNotExist (expected)`);
|
|
215
|
-
}
|
|
216
|
-
return combined;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
throw new NearTransactionError(
|
|
220
|
-
result.stderr || `Transaction failed with code ${result.exitCode}`,
|
|
221
|
-
);
|
|
222
|
-
},
|
|
223
|
-
catch: (error) => error as Error,
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
const txHashMatch = output.match(/Transaction ID:\s*([A-Za-z0-9]+)/i);
|
|
227
|
-
|
|
228
|
-
return {
|
|
229
|
-
success: true,
|
|
230
|
-
txHash: txHashMatch?.[1],
|
|
231
|
-
};
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
export async function addFunctionCallAccessKey(
|
|
235
|
-
config: FunctionCallAccessKeyConfig,
|
|
236
|
-
): Promise<NearKeyPair> {
|
|
237
|
-
const keyPair = generateNearKeyPair();
|
|
238
|
-
const args = [
|
|
239
|
-
"account",
|
|
240
|
-
"add-key",
|
|
241
|
-
config.account,
|
|
242
|
-
"grant-function-call-access",
|
|
243
|
-
"--allowance",
|
|
244
|
-
config.allowance,
|
|
245
|
-
"--contract-account-id",
|
|
246
|
-
config.contract,
|
|
247
|
-
"--function-names",
|
|
248
|
-
config.functionNames.join(", "),
|
|
249
|
-
"use-manually-provided-public-key",
|
|
250
|
-
keyPair.publicKey,
|
|
251
|
-
"network-config",
|
|
252
|
-
config.network || (config.account.endsWith(".testnet") ? "testnet" : "mainnet"),
|
|
253
|
-
"sign-with-keychain",
|
|
254
|
-
"send",
|
|
255
|
-
];
|
|
256
|
-
|
|
257
|
-
await runNearCommand(args);
|
|
258
|
-
return keyPair;
|
|
259
|
-
}
|
package/src/network.ts
DELETED