@veilux/sdk 0.3.0 → 0.3.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/builders.d.ts +3 -0
- package/dist/builders.js +17 -0
- package/dist/client.d.ts +22 -1
- package/dist/client.js +38 -0
- package/dist/types.d.ts +70 -0
- package/dist/types.js +9 -0
- package/package.json +3 -3
package/dist/builders.d.ts
CHANGED
|
@@ -5,3 +5,6 @@ export declare function nftCreateCollection(submitter: PartyId, visibility: Visi
|
|
|
5
5
|
export declare function storagePut(submitter: PartyId, visibility: Visibility, nonce: number, key: string, data: Uint8Array | number[]): Command;
|
|
6
6
|
export declare function contractDeploy(submitter: PartyId, visibility: Visibility, nonce: number, code: Uint8Array | number[]): Command;
|
|
7
7
|
export declare function contractCall(submitter: PartyId, visibility: Visibility, nonce: number, addressHex: string, args: number[], value: number, gasLimit: number): Command;
|
|
8
|
+
export type ForeignChain = "cosmos" | "solana" | "ethereum" | "custom";
|
|
9
|
+
export declare function bridgeRegisterChain(submitter: PartyId, visibility: Visibility, nonce: number, chain: ForeignChain, guardians: string[], quorum: number): Command;
|
|
10
|
+
export declare function bridgeSend(submitter: PartyId, visibility: Visibility, nonce: number, chain: ForeignChain, recipient: string, tokenIdHex: string, amount: bigint | number | string): Command;
|
package/dist/builders.js
CHANGED
|
@@ -71,3 +71,20 @@ export function contractCall(submitter, visibility, nonce, addressHex, args, val
|
|
|
71
71
|
gas_limit: gasLimit,
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
|
+
export function bridgeRegisterChain(submitter, visibility, nonce, chain, guardians, quorum) {
|
|
75
|
+
return cmd("bridge", submitter, visibility, nonce, {
|
|
76
|
+
op: "register_chain",
|
|
77
|
+
chain,
|
|
78
|
+
guardians,
|
|
79
|
+
quorum,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
export function bridgeSend(submitter, visibility, nonce, chain, recipient, tokenIdHex, amount) {
|
|
83
|
+
return cmd("bridge", submitter, visibility, nonce, {
|
|
84
|
+
op: "send",
|
|
85
|
+
chain,
|
|
86
|
+
recipient,
|
|
87
|
+
token_id: hashBytes(tokenIdHex),
|
|
88
|
+
amount: String(amount),
|
|
89
|
+
});
|
|
90
|
+
}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BlockView, type EstimateResult, type NodeInfo, type SignedCommand, type StateResult, type SubmitResult } from "./types.js";
|
|
1
|
+
import { type BlockView, type ChainStats, type CommandLocation, type ContractCode, type EstimateResult, type EventView, type NodeInfo, type SignedCommand, type StatePrefixResult, type StateResult, type SubmitResult, type VerifyRequest, type VerifyResult } from "./types.js";
|
|
2
2
|
export declare class RpcClientError extends Error {
|
|
3
3
|
code: number;
|
|
4
4
|
constructor(code: number, message: string);
|
|
@@ -28,4 +28,25 @@ export declare class Client {
|
|
|
28
28
|
timeoutMs?: number;
|
|
29
29
|
intervalMs?: number;
|
|
30
30
|
}): Promise<number>;
|
|
31
|
+
/** Chain-wide statistics for dashboards. */
|
|
32
|
+
explorerStats(): Promise<ChainStats>;
|
|
33
|
+
/** The most recent blocks, newest first. */
|
|
34
|
+
recentBlocks(limit?: number): Promise<BlockView[]>;
|
|
35
|
+
/** Look up a block by its hash. */
|
|
36
|
+
blockByHash(hash: string): Promise<BlockView>;
|
|
37
|
+
/** Locate a command by id and return its block + produced events. */
|
|
38
|
+
searchCommand(commandId: string): Promise<CommandLocation>;
|
|
39
|
+
/** Recent events emitted by a given Prism (e.g. "token", "bridge"). */
|
|
40
|
+
listByPrism(prism: string, limit?: number): Promise<EventView[]>;
|
|
41
|
+
/** List state entries under a key prefix (e.g. "token/meta/"). */
|
|
42
|
+
statePrefix(prefix: string, limit?: number): Promise<StatePrefixResult>;
|
|
43
|
+
/** Fetch a contract's deployed bytecode + verification status. */
|
|
44
|
+
contractGetCode(address: string): Promise<ContractCode>;
|
|
45
|
+
/** Verify a contract's source against its on-chain bytecode. */
|
|
46
|
+
contractVerify(request: VerifyRequest): Promise<VerifyResult>;
|
|
47
|
+
/** Get a stored verification record, if any. */
|
|
48
|
+
contractGetVerification(address: string): Promise<{
|
|
49
|
+
found: boolean;
|
|
50
|
+
record?: unknown;
|
|
51
|
+
}>;
|
|
31
52
|
}
|
package/dist/client.js
CHANGED
|
@@ -85,4 +85,42 @@ export class Client {
|
|
|
85
85
|
await new Promise((r) => setTimeout(r, intervalMs));
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
+
// ---- Explorer queries ----
|
|
89
|
+
/** Chain-wide statistics for dashboards. */
|
|
90
|
+
explorerStats() {
|
|
91
|
+
return this.call(RPC_METHODS.explorerStats, {});
|
|
92
|
+
}
|
|
93
|
+
/** The most recent blocks, newest first. */
|
|
94
|
+
recentBlocks(limit = 20) {
|
|
95
|
+
return this.call(RPC_METHODS.explorerRecentBlocks, { limit });
|
|
96
|
+
}
|
|
97
|
+
/** Look up a block by its hash. */
|
|
98
|
+
blockByHash(hash) {
|
|
99
|
+
return this.call(RPC_METHODS.explorerBlockByHash, { hash });
|
|
100
|
+
}
|
|
101
|
+
/** Locate a command by id and return its block + produced events. */
|
|
102
|
+
searchCommand(commandId) {
|
|
103
|
+
return this.call(RPC_METHODS.explorerSearchCommand, { command_id: commandId });
|
|
104
|
+
}
|
|
105
|
+
/** Recent events emitted by a given Prism (e.g. "token", "bridge"). */
|
|
106
|
+
listByPrism(prism, limit = 50) {
|
|
107
|
+
return this.call(RPC_METHODS.explorerListByPrism, { prism, limit });
|
|
108
|
+
}
|
|
109
|
+
/** List state entries under a key prefix (e.g. "token/meta/"). */
|
|
110
|
+
statePrefix(prefix, limit = 100) {
|
|
111
|
+
return this.call(RPC_METHODS.explorerStatePrefix, { prefix, limit });
|
|
112
|
+
}
|
|
113
|
+
// ---- Contract verification ----
|
|
114
|
+
/** Fetch a contract's deployed bytecode + verification status. */
|
|
115
|
+
contractGetCode(address) {
|
|
116
|
+
return this.call(RPC_METHODS.contractGetCode, { address });
|
|
117
|
+
}
|
|
118
|
+
/** Verify a contract's source against its on-chain bytecode. */
|
|
119
|
+
contractVerify(request) {
|
|
120
|
+
return this.call(RPC_METHODS.contractVerify, request);
|
|
121
|
+
}
|
|
122
|
+
/** Get a stored verification record, if any. */
|
|
123
|
+
contractGetVerification(address) {
|
|
124
|
+
return this.call(RPC_METHODS.contractGetVerification, { address });
|
|
125
|
+
}
|
|
88
126
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -73,4 +73,74 @@ export declare const RPC_METHODS: {
|
|
|
73
73
|
readonly getBlockByNumber: "veilux_getBlockByNumber";
|
|
74
74
|
readonly getState: "veilux_getState";
|
|
75
75
|
readonly estimate: "veilux_estimate";
|
|
76
|
+
readonly explorerStats: "explorer_stats";
|
|
77
|
+
readonly explorerRecentBlocks: "explorer_recentBlocks";
|
|
78
|
+
readonly explorerBlockByHash: "explorer_blockByHash";
|
|
79
|
+
readonly explorerSearchCommand: "explorer_searchCommand";
|
|
80
|
+
readonly explorerListByPrism: "explorer_listByPrism";
|
|
81
|
+
readonly explorerStatePrefix: "explorer_statePrefix";
|
|
82
|
+
readonly contractGetCode: "contract_getCode";
|
|
83
|
+
readonly contractVerify: "contract_verify";
|
|
84
|
+
readonly contractGetVerification: "contract_getVerification";
|
|
76
85
|
};
|
|
86
|
+
export interface ChainStats {
|
|
87
|
+
height: number;
|
|
88
|
+
total_blocks: number;
|
|
89
|
+
total_commands: number;
|
|
90
|
+
total_events: number;
|
|
91
|
+
head_hash: string;
|
|
92
|
+
state_root: string;
|
|
93
|
+
state_entries: number;
|
|
94
|
+
events_by_prism: Record<string, number>;
|
|
95
|
+
}
|
|
96
|
+
export interface EventView {
|
|
97
|
+
block_height: number;
|
|
98
|
+
prism: string;
|
|
99
|
+
commitment: string;
|
|
100
|
+
source_command: string;
|
|
101
|
+
visibility: string;
|
|
102
|
+
redacted: boolean;
|
|
103
|
+
stakeholders: number;
|
|
104
|
+
payload_json: unknown | null;
|
|
105
|
+
payload_hex: string | null;
|
|
106
|
+
}
|
|
107
|
+
export interface CommandLocation {
|
|
108
|
+
found: boolean;
|
|
109
|
+
command_id: string;
|
|
110
|
+
block_height: number | null;
|
|
111
|
+
block_hash: string | null;
|
|
112
|
+
prism: string | null;
|
|
113
|
+
submitter: string | null;
|
|
114
|
+
events: EventView[];
|
|
115
|
+
}
|
|
116
|
+
export interface StateEntry {
|
|
117
|
+
key: string;
|
|
118
|
+
value_hex: string;
|
|
119
|
+
}
|
|
120
|
+
export interface StatePrefixResult {
|
|
121
|
+
prefix: string;
|
|
122
|
+
total: number;
|
|
123
|
+
entries: StateEntry[];
|
|
124
|
+
}
|
|
125
|
+
export interface ContractCode {
|
|
126
|
+
address: string;
|
|
127
|
+
found: boolean;
|
|
128
|
+
deployer: string | null;
|
|
129
|
+
bytecode_hex: string;
|
|
130
|
+
code_size: number;
|
|
131
|
+
code_hash: string;
|
|
132
|
+
verified: boolean;
|
|
133
|
+
}
|
|
134
|
+
export interface VerifyRequest {
|
|
135
|
+
address: string;
|
|
136
|
+
name: string;
|
|
137
|
+
source: string;
|
|
138
|
+
bytecode_hex: string;
|
|
139
|
+
compiler: string;
|
|
140
|
+
abi?: string;
|
|
141
|
+
}
|
|
142
|
+
export interface VerifyResult {
|
|
143
|
+
verified: boolean;
|
|
144
|
+
message: string;
|
|
145
|
+
code_hash: string;
|
|
146
|
+
}
|
package/dist/types.js
CHANGED
|
@@ -6,4 +6,13 @@ export const RPC_METHODS = {
|
|
|
6
6
|
getBlockByNumber: "veilux_getBlockByNumber",
|
|
7
7
|
getState: "veilux_getState",
|
|
8
8
|
estimate: "veilux_estimate",
|
|
9
|
+
explorerStats: "explorer_stats",
|
|
10
|
+
explorerRecentBlocks: "explorer_recentBlocks",
|
|
11
|
+
explorerBlockByHash: "explorer_blockByHash",
|
|
12
|
+
explorerSearchCommand: "explorer_searchCommand",
|
|
13
|
+
explorerListByPrism: "explorer_listByPrism",
|
|
14
|
+
explorerStatePrefix: "explorer_statePrefix",
|
|
15
|
+
contractGetCode: "contract_getCode",
|
|
16
|
+
contractVerify: "contract_verify",
|
|
17
|
+
contractGetVerification: "contract_getVerification",
|
|
9
18
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veilux/sdk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "VEILUX TypeScript SDK — build, sign, and submit commands to a VEILUX node",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "nathan <nathan@winnode.xyz>",
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"build": "tsc",
|
|
26
|
+
"build:examples": "tsc -p examples/tsconfig.json",
|
|
26
27
|
"pretest": "tsc && tsc test/compat.test.ts --rootDir test --outDir test-dist --module ESNext --target ES2020 --moduleResolution Bundler --skipLibCheck --types node",
|
|
27
28
|
"test": "node --test test-dist/",
|
|
28
|
-
"
|
|
29
|
-
"clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true});require('fs').rmSync('test-dist',{recursive:true,force:true})\""
|
|
29
|
+
"clean": "node -e \"['dist','test-dist','examples-dist'].forEach(d=>require('fs').rmSync(d,{recursive:true,force:true}))\""
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@noble/ed25519": "^2.1.0",
|