@lobstercove/lichen-sdk 1.0.1 → 1.0.3

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.
@@ -127,6 +127,13 @@ export declare class Connection {
127
127
  * Make an RPC call
128
128
  */
129
129
  private rpc;
130
+ /**
131
+ * Make a raw JSON-RPC request.
132
+ *
133
+ * SDK feature clients use this to expose typed wrappers without duplicating
134
+ * timeout, HTTP, and JSON-RPC error handling.
135
+ */
136
+ rpcRequest<T = any>(method: string, params?: any[]): Promise<T>;
130
137
  /**
131
138
  * Get account balance
132
139
  */
@@ -361,6 +368,22 @@ export declare class Connection {
361
368
  * Get aggregated SporeVault yield-vault statistics.
362
369
  */
363
370
  getSporeVaultStats(): Promise<any>;
371
+ /**
372
+ * Get aggregated Neo GAS rewards vault statistics.
373
+ */
374
+ getNeoGasRewardsStats(): Promise<any>;
375
+ /**
376
+ * Get per-wallet Neo GAS rewards vault accounting.
377
+ */
378
+ getNeoGasRewardsPosition(address: PublicKey | string): Promise<any>;
379
+ /**
380
+ * Get Neo reserve/liability proof-service verifier metadata.
381
+ */
382
+ getNeoZkProofServiceStatus(): Promise<any>;
383
+ /**
384
+ * Verify a CLI-produced Neo reserve/liability proof envelope.
385
+ */
386
+ verifyNeoReserveLiabilityProof(proofEnvelope: any): Promise<any>;
364
387
  /**
365
388
  * Get aggregated BountyBoard marketplace statistics.
366
389
  */
@@ -58,6 +58,15 @@ export class Connection {
58
58
  }
59
59
  return data.result;
60
60
  }
61
+ /**
62
+ * Make a raw JSON-RPC request.
63
+ *
64
+ * SDK feature clients use this to expose typed wrappers without duplicating
65
+ * timeout, HTTP, and JSON-RPC error handling.
66
+ */
67
+ async rpcRequest(method, params = []) {
68
+ return this.rpc(method, params);
69
+ }
61
70
  // ============================================================================
62
71
  // BASIC QUERIES
63
72
  // ============================================================================
@@ -474,6 +483,31 @@ export class Connection {
474
483
  async getSporeVaultStats() {
475
484
  return this.rpc('getSporeVaultStats');
476
485
  }
486
+ /**
487
+ * Get aggregated Neo GAS rewards vault statistics.
488
+ */
489
+ async getNeoGasRewardsStats() {
490
+ return this.rpc('getNeoGasRewardsStats');
491
+ }
492
+ /**
493
+ * Get per-wallet Neo GAS rewards vault accounting.
494
+ */
495
+ async getNeoGasRewardsPosition(address) {
496
+ const value = typeof address === 'string' ? address : address.toBase58();
497
+ return this.rpc('getNeoGasRewardsPosition', [value]);
498
+ }
499
+ /**
500
+ * Get Neo reserve/liability proof-service verifier metadata.
501
+ */
502
+ async getNeoZkProofServiceStatus() {
503
+ return this.rpc('getNeoZkProofServiceStatus');
504
+ }
505
+ /**
506
+ * Verify a CLI-produced Neo reserve/liability proof envelope.
507
+ */
508
+ async verifyNeoReserveLiabilityProof(proofEnvelope) {
509
+ return this.rpc('verifyNeoReserveLiabilityProof', [proofEnvelope]);
510
+ }
477
511
  /**
478
512
  * Get aggregated BountyBoard marketplace statistics.
479
513
  */
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@ export { LichenSwapClient } from './lichenswap.js';
8
8
  export { SporePayClient } from './sporepay.js';
9
9
  export { SporeVaultClient } from './sporevault.js';
10
10
  export { BountyBoardClient } from './bountyboard.js';
11
+ export { BRIDGE_ASSETS, BRIDGE_CHAINS, RestrictionGovernanceClient, } from './restrictions.js';
11
12
  export { ML_DSA_65_PUBLIC_KEY_BYTES, ML_DSA_65_SIGNATURE_BYTES, PQ_SCHEME_ML_DSA_65, PqPublicKey, PqSignature, } from './pq.js';
12
13
  export { Transaction, TransactionBuilder, Instruction, Message, } from './transaction.js';
13
14
  export type { Balance, Account, Block, Validator, NetworkInfo, ChainStatus, Metrics, ProofStep, ReadonlyContractResult, TransactionProof, } from './connection.js';
@@ -17,11 +18,12 @@ export type { AddLiquidityParams, CreatePoolParams, LichenSwapPoolInfo, LichenSw
17
18
  export type { CreateStreamParams, CreateStreamWithCliffParams, SporePayStats, SporePayStream, SporePayStreamInfo, TransferStreamParams, WithdrawFromStreamParams, } from './sporepay.js';
18
19
  export type { SporeVaultStats, SporeVaultStrategyInfo, SporeVaultUserPosition, SporeVaultVaultStats, } from './sporevault.js';
19
20
  export type { ApproveWorkParams, BountyBoardBountyInfo, BountyBoardPlatformStats, BountyBoardStats, CreateBountyParams, SubmitWorkParams, } from './bountyboard.js';
21
+ export type { AccountAssetRestrictionTarget, AccountRestrictionTarget, AddressInput, AssetRestrictionTarget, BridgeAsset, BridgeChain, BridgeRouteRestrictionParams, BridgeRouteRestrictionStatus, BridgeRouteRestrictionTarget, CodeHashRestrictionParams, CodeHashRestrictionStatus, CodeHashRestrictionTarget, ContractLifecycleRestrictionStatus, ContractRestrictionParams, ContractRestrictionTarget, EffectiveRestrictionRecord, ExtendRestrictionParams, GetRestrictionResponse, LiftRestrictionParams, MovementRestrictionParams, MovementRestrictionStatus, ProtocolModuleRestrictionTarget, RestrictAccountAssetParams, RestrictAccountParams, RestrictionAssetInput, RestrictionBuilderBaseParams, RestrictionBuilderInstruction, RestrictionLiftReason, RestrictionLiftReasonInput, RestrictionListParams, RestrictionListResponse, RestrictionMode, RestrictionModeDetails, RestrictionModeInput, RestrictionReason, RestrictionReasonInput, RestrictionRecord, RestrictionTargetDetails, RestrictionTargetInput, RestrictionTargetStatus, RestrictionTargetType, ResumeBridgeRouteParams, ResumeContractParams, SetFrozenAssetAmountParams, TransferRestrictionParams, TransferRestrictionStatus, UnbanCodeHashParams, UnrestrictAccountAssetParams, UnrestrictAccountParams, UnsignedRestrictionGovernanceTx, } from './restrictions.js';
20
22
  export { BOUNTY_STATUS_OPEN, BOUNTY_STATUS_COMPLETED, BOUNTY_STATUS_CANCELLED, } from './bountyboard.js';
21
23
  /**
22
24
  * SDK version
23
25
  */
24
- export declare const VERSION = "1.0.0";
26
+ export declare const VERSION = "1.0.2";
25
27
  /**
26
28
  * Default RPC URL (override with LICHEN_RPC_URL env var)
27
29
  */
package/dist/index.js CHANGED
@@ -10,13 +10,14 @@ export { LichenSwapClient } from './lichenswap.js';
10
10
  export { SporePayClient } from './sporepay.js';
11
11
  export { SporeVaultClient } from './sporevault.js';
12
12
  export { BountyBoardClient } from './bountyboard.js';
13
+ export { BRIDGE_ASSETS, BRIDGE_CHAINS, RestrictionGovernanceClient, } from './restrictions.js';
13
14
  export { ML_DSA_65_PUBLIC_KEY_BYTES, ML_DSA_65_SIGNATURE_BYTES, PQ_SCHEME_ML_DSA_65, PqPublicKey, PqSignature, } from './pq.js';
14
15
  export { TransactionBuilder, } from './transaction.js';
15
16
  export { BOUNTY_STATUS_OPEN, BOUNTY_STATUS_COMPLETED, BOUNTY_STATUS_CANCELLED, } from './bountyboard.js';
16
17
  /**
17
18
  * SDK version
18
19
  */
19
- export const VERSION = '1.0.0';
20
+ export const VERSION = '1.0.2';
20
21
  /**
21
22
  * Default RPC URL (override with LICHEN_RPC_URL env var)
22
23
  */
@@ -0,0 +1,342 @@
1
+ import type { Connection } from './connection.js';
2
+ import { PublicKey } from './publickey.js';
3
+ type RpcConnection = Pick<Connection, 'rpcRequest'>;
4
+ export type AddressInput = PublicKey | string;
5
+ export type RestrictionAssetInput = PublicKey | string;
6
+ export type RestrictionTargetType = 'account' | 'account_asset' | 'asset' | 'contract' | 'code_hash' | 'bridge_route' | 'protocol_module';
7
+ export type RestrictionMode = 'outgoing_only' | 'incoming_only' | 'bidirectional' | 'frozen_amount' | 'asset_paused' | 'execute_blocked' | 'state_changing_blocked' | 'quarantined' | 'deploy_blocked' | 'route_paused' | 'protocol_paused' | 'terminated';
8
+ export type RestrictionReason = 'exploit_active' | 'stolen_funds' | 'bridge_compromise' | 'oracle_compromise' | 'scam_contract' | 'malicious_code_hash' | 'sanctions_or_legal_order' | 'phishing_or_impersonation' | 'custody_incident' | 'protocol_bug' | 'governance_error_correction' | 'false_positive_lift' | 'testnet_drill';
9
+ export type RestrictionLiftReason = 'incident_resolved' | 'false_positive' | 'evidence_rejected' | 'governance_override' | 'expired_cleanup' | 'testnet_drill_complete';
10
+ export type RestrictionReasonInput = RestrictionReason | number;
11
+ export type RestrictionLiftReasonInput = RestrictionLiftReason | number;
12
+ export type RestrictionModeInput = RestrictionMode | number;
13
+ export declare const BRIDGE_CHAINS: Readonly<{
14
+ readonly SOLANA: "solana";
15
+ readonly ETHEREUM: "ethereum";
16
+ readonly BSC: "bsc";
17
+ readonly BNB: "bnb";
18
+ readonly NEOX: "neox";
19
+ }>;
20
+ export type BridgeChain = typeof BRIDGE_CHAINS[keyof typeof BRIDGE_CHAINS];
21
+ export declare const BRIDGE_ASSETS: Readonly<{
22
+ readonly SOL: "sol";
23
+ readonly ETH: "eth";
24
+ readonly BNB: "bnb";
25
+ readonly GAS: "gas";
26
+ readonly NEO: "neo";
27
+ readonly USDC: "usdc";
28
+ readonly USDT: "usdt";
29
+ }>;
30
+ export type BridgeAsset = typeof BRIDGE_ASSETS[keyof typeof BRIDGE_ASSETS];
31
+ export interface AccountRestrictionTarget {
32
+ type: 'account';
33
+ account: AddressInput;
34
+ }
35
+ export interface AccountAssetRestrictionTarget {
36
+ type: 'account_asset';
37
+ account: AddressInput;
38
+ asset: RestrictionAssetInput;
39
+ }
40
+ export interface AssetRestrictionTarget {
41
+ type: 'asset';
42
+ asset: RestrictionAssetInput;
43
+ }
44
+ export interface ContractRestrictionTarget {
45
+ type: 'contract';
46
+ contract: AddressInput;
47
+ }
48
+ export interface CodeHashRestrictionTarget {
49
+ type: 'code_hash';
50
+ codeHash?: string;
51
+ code_hash?: string;
52
+ }
53
+ export interface BridgeRouteRestrictionTarget {
54
+ type: 'bridge_route';
55
+ chain: BridgeChain | string;
56
+ asset: BridgeAsset | string;
57
+ }
58
+ export interface ProtocolModuleRestrictionTarget {
59
+ type: 'protocol_module';
60
+ module: string | number;
61
+ }
62
+ export type RestrictionTargetInput = AccountRestrictionTarget | AccountAssetRestrictionTarget | AssetRestrictionTarget | ContractRestrictionTarget | CodeHashRestrictionTarget | BridgeRouteRestrictionTarget | ProtocolModuleRestrictionTarget;
63
+ export interface RestrictionTargetDetails {
64
+ type: RestrictionTargetType | string;
65
+ account?: string;
66
+ asset?: string;
67
+ contract?: string;
68
+ code_hash?: string;
69
+ chain?: string;
70
+ chain_id?: string;
71
+ module?: string;
72
+ module_id?: number;
73
+ }
74
+ export interface RestrictionModeDetails {
75
+ kind: RestrictionMode | string;
76
+ frozen_amount?: number | null;
77
+ }
78
+ export interface RestrictionRecord {
79
+ id: number;
80
+ status: string;
81
+ target_type: RestrictionTargetType | string;
82
+ target: string;
83
+ target_details: RestrictionTargetDetails;
84
+ mode: RestrictionMode | string;
85
+ mode_details: RestrictionModeDetails;
86
+ frozen_amount?: number | null;
87
+ reason: RestrictionReason | string;
88
+ evidence_hash?: string | null;
89
+ evidence_uri_hash?: string | null;
90
+ proposer: string;
91
+ authority: string;
92
+ approval_authority?: string | null;
93
+ created_slot: number;
94
+ created_epoch: number;
95
+ expires_at_slot?: number | null;
96
+ supersedes?: number | null;
97
+ lifted_by?: string | null;
98
+ lifted_slot?: number | null;
99
+ lift_reason?: RestrictionLiftReason | string | null;
100
+ }
101
+ export interface EffectiveRestrictionRecord extends RestrictionRecord {
102
+ effective_status: string;
103
+ active: boolean;
104
+ }
105
+ export interface GetRestrictionResponse {
106
+ id: number;
107
+ slot: number;
108
+ found: boolean;
109
+ restriction: EffectiveRestrictionRecord | null;
110
+ }
111
+ export interface RestrictionListParams {
112
+ limit?: number | bigint;
113
+ afterId?: number | bigint;
114
+ cursor?: number | bigint | string;
115
+ }
116
+ export interface RestrictionListResponse {
117
+ restrictions: EffectiveRestrictionRecord[];
118
+ count: number;
119
+ has_more: boolean;
120
+ next_cursor?: string | null;
121
+ slot: number;
122
+ active_only?: boolean;
123
+ }
124
+ export interface RestrictionTargetStatus {
125
+ slot: number;
126
+ target_type: RestrictionTargetType | string;
127
+ target: string;
128
+ target_details: RestrictionTargetDetails;
129
+ restricted: boolean;
130
+ active: boolean;
131
+ restriction_ids: number[];
132
+ active_restriction_ids: number[];
133
+ restrictions: EffectiveRestrictionRecord[];
134
+ active_restrictions: EffectiveRestrictionRecord[];
135
+ }
136
+ export interface ContractLifecycleRestrictionStatus {
137
+ contract: string;
138
+ slot: number;
139
+ found: boolean;
140
+ is_executable: boolean;
141
+ lifecycle_status: string;
142
+ lifecycle_updated_slot: number;
143
+ lifecycle_restriction_id?: number | null;
144
+ derived_from_restriction: boolean;
145
+ active: boolean;
146
+ active_restriction_ids: number[];
147
+ active_restrictions: EffectiveRestrictionRecord[];
148
+ }
149
+ export interface CodeHashRestrictionStatus {
150
+ code_hash: string;
151
+ slot: number;
152
+ blocked: boolean;
153
+ deploy_blocked: boolean;
154
+ active_restriction_ids: number[];
155
+ active_restrictions: RestrictionRecord[];
156
+ }
157
+ export interface BridgeRouteRestrictionStatus {
158
+ chain: string;
159
+ chain_id: string;
160
+ asset: string;
161
+ slot: number;
162
+ paused: boolean;
163
+ route_paused: boolean;
164
+ active_restriction_ids: number[];
165
+ active_restrictions: RestrictionRecord[];
166
+ }
167
+ export interface MovementRestrictionStatus {
168
+ operation: 'send' | 'receive';
169
+ account: string;
170
+ asset: string;
171
+ amount: number;
172
+ spendable: number;
173
+ slot: number;
174
+ allowed: boolean;
175
+ blocked: boolean;
176
+ active_restriction_ids: number[];
177
+ active_restrictions: RestrictionRecord[];
178
+ }
179
+ export interface TransferRestrictionStatus {
180
+ operation: 'transfer';
181
+ from: string;
182
+ to: string;
183
+ asset: string;
184
+ amount: number;
185
+ source_spendable: number;
186
+ recipient_spendable: number;
187
+ slot: number;
188
+ allowed: boolean;
189
+ blocked: boolean;
190
+ send_allowed: boolean;
191
+ receive_allowed: boolean;
192
+ source_blocked: boolean;
193
+ recipient_blocked: boolean;
194
+ source_restriction_ids: number[];
195
+ source_restrictions: RestrictionRecord[];
196
+ recipient_restriction_ids: number[];
197
+ recipient_restrictions: RestrictionRecord[];
198
+ active_restriction_ids: number[];
199
+ active_restrictions: RestrictionRecord[];
200
+ }
201
+ export interface RestrictionBuilderInstruction {
202
+ program_id: string;
203
+ accounts: string[];
204
+ instruction_type: number;
205
+ governance_action_type?: number | null;
206
+ data_hex: string;
207
+ }
208
+ export interface UnsignedRestrictionGovernanceTx {
209
+ method: string;
210
+ unsigned: true;
211
+ encoding: 'base64';
212
+ wire_format: string;
213
+ tx_type: 'native';
214
+ transaction_base64: string;
215
+ transaction: string;
216
+ wire_size: number;
217
+ message_hash: string;
218
+ signature_count: number;
219
+ recent_blockhash: string;
220
+ slot?: number | null;
221
+ proposer: string;
222
+ governance_authority: string;
223
+ action_label: 'restrict' | 'lift_restriction' | 'extend_restriction' | string;
224
+ action: Record<string, unknown>;
225
+ instruction: RestrictionBuilderInstruction;
226
+ }
227
+ export interface RestrictionBuilderBaseParams {
228
+ proposer: AddressInput;
229
+ governanceAuthority: AddressInput;
230
+ recentBlockhash?: string;
231
+ }
232
+ export interface RestrictCommonParams extends RestrictionBuilderBaseParams {
233
+ reason: RestrictionReasonInput;
234
+ evidenceHash?: string;
235
+ evidenceUriHash?: string;
236
+ expiresAtSlot?: number | bigint;
237
+ }
238
+ export interface RestrictAccountParams extends RestrictCommonParams {
239
+ account: AddressInput;
240
+ mode?: RestrictionModeInput;
241
+ }
242
+ export interface UnrestrictAccountParams extends RestrictionBuilderBaseParams {
243
+ account: AddressInput;
244
+ restrictionId?: number | bigint;
245
+ liftReason: RestrictionLiftReasonInput;
246
+ }
247
+ export interface RestrictAccountAssetParams extends RestrictCommonParams {
248
+ account: AddressInput;
249
+ asset: RestrictionAssetInput;
250
+ mode?: RestrictionModeInput;
251
+ }
252
+ export interface UnrestrictAccountAssetParams extends RestrictionBuilderBaseParams {
253
+ account: AddressInput;
254
+ asset: RestrictionAssetInput;
255
+ restrictionId?: number | bigint;
256
+ liftReason: RestrictionLiftReasonInput;
257
+ }
258
+ export interface SetFrozenAssetAmountParams extends RestrictCommonParams {
259
+ account: AddressInput;
260
+ asset: RestrictionAssetInput;
261
+ amount: number | bigint;
262
+ }
263
+ export interface ContractRestrictionParams extends RestrictCommonParams {
264
+ contract: AddressInput;
265
+ }
266
+ export interface ResumeContractParams extends RestrictionBuilderBaseParams {
267
+ contract: AddressInput;
268
+ restrictionId?: number | bigint;
269
+ liftReason: RestrictionLiftReasonInput;
270
+ }
271
+ export interface CodeHashRestrictionParams extends RestrictCommonParams {
272
+ codeHash: string;
273
+ }
274
+ export interface UnbanCodeHashParams extends RestrictionBuilderBaseParams {
275
+ codeHash: string;
276
+ restrictionId?: number | bigint;
277
+ liftReason: RestrictionLiftReasonInput;
278
+ }
279
+ export interface BridgeRouteRestrictionParams extends RestrictCommonParams {
280
+ chain: BridgeChain | string;
281
+ asset: BridgeAsset | string;
282
+ }
283
+ export interface ResumeBridgeRouteParams extends RestrictionBuilderBaseParams {
284
+ chain: BridgeChain | string;
285
+ asset: BridgeAsset | string;
286
+ restrictionId?: number | bigint;
287
+ liftReason: RestrictionLiftReasonInput;
288
+ }
289
+ export interface ExtendRestrictionParams extends RestrictionBuilderBaseParams {
290
+ restrictionId: number | bigint;
291
+ newExpiresAtSlot?: number | bigint;
292
+ evidenceHash?: string;
293
+ }
294
+ export interface LiftRestrictionParams extends RestrictionBuilderBaseParams {
295
+ restrictionId: number | bigint;
296
+ liftReason: RestrictionLiftReasonInput;
297
+ }
298
+ export interface MovementRestrictionParams {
299
+ account: AddressInput;
300
+ asset: RestrictionAssetInput;
301
+ amount?: number | bigint;
302
+ }
303
+ export interface TransferRestrictionParams {
304
+ from: AddressInput;
305
+ to: AddressInput;
306
+ asset: RestrictionAssetInput;
307
+ amount?: number | bigint;
308
+ }
309
+ export declare class RestrictionGovernanceClient {
310
+ private readonly connection;
311
+ constructor(connection: RpcConnection);
312
+ private rpc;
313
+ getRestriction(restrictionId: number | bigint): Promise<GetRestrictionResponse>;
314
+ listRestrictions(params?: RestrictionListParams): Promise<RestrictionListResponse>;
315
+ listActiveRestrictions(params?: RestrictionListParams): Promise<RestrictionListResponse>;
316
+ getRestrictionStatus(target: RestrictionTargetInput): Promise<RestrictionTargetStatus>;
317
+ getAccountRestrictionStatus(account: AddressInput): Promise<RestrictionTargetStatus>;
318
+ getAssetRestrictionStatus(assetId: RestrictionAssetInput): Promise<RestrictionTargetStatus>;
319
+ getAccountAssetRestrictionStatus(account: AddressInput, assetId: RestrictionAssetInput): Promise<RestrictionTargetStatus>;
320
+ getContractLifecycleStatus(contract: AddressInput): Promise<ContractLifecycleRestrictionStatus>;
321
+ getCodeHashRestrictionStatus(codeHash: string): Promise<CodeHashRestrictionStatus>;
322
+ getBridgeRouteRestrictionStatus(chain: BridgeChain | string, asset: BridgeAsset | string): Promise<BridgeRouteRestrictionStatus>;
323
+ canSend(params: MovementRestrictionParams): Promise<MovementRestrictionStatus>;
324
+ canReceive(params: MovementRestrictionParams): Promise<MovementRestrictionStatus>;
325
+ canTransfer(params: TransferRestrictionParams): Promise<TransferRestrictionStatus>;
326
+ buildRestrictAccountTx(params: RestrictAccountParams): Promise<UnsignedRestrictionGovernanceTx>;
327
+ buildUnrestrictAccountTx(params: UnrestrictAccountParams): Promise<UnsignedRestrictionGovernanceTx>;
328
+ buildRestrictAccountAssetTx(params: RestrictAccountAssetParams): Promise<UnsignedRestrictionGovernanceTx>;
329
+ buildUnrestrictAccountAssetTx(params: UnrestrictAccountAssetParams): Promise<UnsignedRestrictionGovernanceTx>;
330
+ buildSetFrozenAssetAmountTx(params: SetFrozenAssetAmountParams): Promise<UnsignedRestrictionGovernanceTx>;
331
+ buildSuspendContractTx(params: ContractRestrictionParams): Promise<UnsignedRestrictionGovernanceTx>;
332
+ buildResumeContractTx(params: ResumeContractParams): Promise<UnsignedRestrictionGovernanceTx>;
333
+ buildQuarantineContractTx(params: ContractRestrictionParams): Promise<UnsignedRestrictionGovernanceTx>;
334
+ buildTerminateContractTx(params: ContractRestrictionParams): Promise<UnsignedRestrictionGovernanceTx>;
335
+ buildBanCodeHashTx(params: CodeHashRestrictionParams): Promise<UnsignedRestrictionGovernanceTx>;
336
+ buildUnbanCodeHashTx(params: UnbanCodeHashParams): Promise<UnsignedRestrictionGovernanceTx>;
337
+ buildPauseBridgeRouteTx(params: BridgeRouteRestrictionParams): Promise<UnsignedRestrictionGovernanceTx>;
338
+ buildResumeBridgeRouteTx(params: ResumeBridgeRouteParams): Promise<UnsignedRestrictionGovernanceTx>;
339
+ buildExtendRestrictionTx(params: ExtendRestrictionParams): Promise<UnsignedRestrictionGovernanceTx>;
340
+ buildLiftRestrictionTx(params: LiftRestrictionParams): Promise<UnsignedRestrictionGovernanceTx>;
341
+ }
342
+ export {};
@@ -0,0 +1,268 @@
1
+ import { PublicKey } from './publickey.js';
2
+ const MAX_U64 = (1n << 64n) - 1n;
3
+ export const BRIDGE_CHAINS = Object.freeze({
4
+ SOLANA: 'solana',
5
+ ETHEREUM: 'ethereum',
6
+ BSC: 'bsc',
7
+ BNB: 'bnb',
8
+ NEOX: 'neox',
9
+ });
10
+ export const BRIDGE_ASSETS = Object.freeze({
11
+ SOL: 'sol',
12
+ ETH: 'eth',
13
+ BNB: 'bnb',
14
+ GAS: 'gas',
15
+ NEO: 'neo',
16
+ USDC: 'usdc',
17
+ USDT: 'usdt',
18
+ });
19
+ function address(value) {
20
+ return value instanceof PublicKey ? value.toBase58() : value;
21
+ }
22
+ function asset(value) {
23
+ return value instanceof PublicKey ? value.toBase58() : value;
24
+ }
25
+ function u64(value, fieldName) {
26
+ const normalized = typeof value === 'bigint'
27
+ ? value
28
+ : Number.isSafeInteger(value) && value >= 0
29
+ ? BigInt(value)
30
+ : null;
31
+ if (normalized === null || normalized < 0n || normalized > MAX_U64) {
32
+ throw new Error(`${fieldName} must be a u64-safe integer value`);
33
+ }
34
+ return typeof value === 'bigint' ? normalized.toString() : value;
35
+ }
36
+ function optionalU64(value, fieldName) {
37
+ return value === undefined ? undefined : u64(value, fieldName);
38
+ }
39
+ function omitUndefined(value) {
40
+ for (const key of Object.keys(value)) {
41
+ if (value[key] === undefined) {
42
+ delete value[key];
43
+ }
44
+ }
45
+ return value;
46
+ }
47
+ function pageParams(params = {}) {
48
+ return omitUndefined({
49
+ limit: optionalU64(params.limit, 'limit'),
50
+ after_id: params.afterId === undefined ? undefined : u64(params.afterId, 'afterId'),
51
+ cursor: params.cursor === undefined || typeof params.cursor === 'string'
52
+ ? params.cursor
53
+ : u64(params.cursor, 'cursor'),
54
+ });
55
+ }
56
+ function targetParams(target) {
57
+ switch (target.type) {
58
+ case 'account':
59
+ return { type: target.type, account: address(target.account) };
60
+ case 'account_asset':
61
+ return { type: target.type, account: address(target.account), asset: asset(target.asset) };
62
+ case 'asset':
63
+ return { type: target.type, asset: asset(target.asset) };
64
+ case 'contract':
65
+ return { type: target.type, contract: address(target.contract) };
66
+ case 'code_hash': {
67
+ const codeHash = target.codeHash ?? target.code_hash;
68
+ if (!codeHash) {
69
+ throw new Error('codeHash is required');
70
+ }
71
+ return { type: target.type, code_hash: codeHash };
72
+ }
73
+ case 'bridge_route':
74
+ return { type: target.type, chain: target.chain, asset: target.asset };
75
+ case 'protocol_module':
76
+ return { type: target.type, module: target.module };
77
+ }
78
+ }
79
+ function builderBase(params) {
80
+ return omitUndefined({
81
+ proposer: address(params.proposer),
82
+ governance_authority: address(params.governanceAuthority),
83
+ recent_blockhash: params.recentBlockhash,
84
+ });
85
+ }
86
+ function restrictCommon(params) {
87
+ return omitUndefined({
88
+ ...builderBase(params),
89
+ reason: params.reason,
90
+ evidence_hash: params.evidenceHash,
91
+ evidence_uri_hash: params.evidenceUriHash,
92
+ expires_at_slot: optionalU64(params.expiresAtSlot, 'expiresAtSlot'),
93
+ });
94
+ }
95
+ function restrictionIdParam(value) {
96
+ return value === undefined ? undefined : u64(value, 'restrictionId');
97
+ }
98
+ export class RestrictionGovernanceClient {
99
+ constructor(connection) {
100
+ this.connection = connection;
101
+ }
102
+ rpc(method, params = []) {
103
+ return this.connection.rpcRequest(method, params);
104
+ }
105
+ async getRestriction(restrictionId) {
106
+ return this.rpc('getRestriction', [u64(restrictionId, 'restrictionId')]);
107
+ }
108
+ async listRestrictions(params = {}) {
109
+ return this.rpc('listRestrictions', [pageParams(params)]);
110
+ }
111
+ async listActiveRestrictions(params = {}) {
112
+ return this.rpc('listActiveRestrictions', [pageParams(params)]);
113
+ }
114
+ async getRestrictionStatus(target) {
115
+ return this.rpc('getRestrictionStatus', [targetParams(target)]);
116
+ }
117
+ async getAccountRestrictionStatus(account) {
118
+ return this.rpc('getAccountRestrictionStatus', [address(account)]);
119
+ }
120
+ async getAssetRestrictionStatus(assetId) {
121
+ return this.rpc('getAssetRestrictionStatus', [asset(assetId)]);
122
+ }
123
+ async getAccountAssetRestrictionStatus(account, assetId) {
124
+ return this.rpc('getAccountAssetRestrictionStatus', [address(account), asset(assetId)]);
125
+ }
126
+ async getContractLifecycleStatus(contract) {
127
+ return this.rpc('getContractLifecycleStatus', [address(contract)]);
128
+ }
129
+ async getCodeHashRestrictionStatus(codeHash) {
130
+ return this.rpc('getCodeHashRestrictionStatus', [codeHash]);
131
+ }
132
+ async getBridgeRouteRestrictionStatus(chain, asset) {
133
+ return this.rpc('getBridgeRouteRestrictionStatus', [chain, asset]);
134
+ }
135
+ async canSend(params) {
136
+ return this.rpc('canSend', [omitUndefined({
137
+ account: address(params.account),
138
+ asset: asset(params.asset),
139
+ amount: optionalU64(params.amount, 'amount'),
140
+ })]);
141
+ }
142
+ async canReceive(params) {
143
+ return this.rpc('canReceive', [omitUndefined({
144
+ account: address(params.account),
145
+ asset: asset(params.asset),
146
+ amount: optionalU64(params.amount, 'amount'),
147
+ })]);
148
+ }
149
+ async canTransfer(params) {
150
+ return this.rpc('canTransfer', [omitUndefined({
151
+ from: address(params.from),
152
+ to: address(params.to),
153
+ asset: asset(params.asset),
154
+ amount: optionalU64(params.amount, 'amount'),
155
+ })]);
156
+ }
157
+ async buildRestrictAccountTx(params) {
158
+ return this.rpc('buildRestrictAccountTx', [omitUndefined({
159
+ ...restrictCommon(params),
160
+ account: address(params.account),
161
+ mode: params.mode,
162
+ })]);
163
+ }
164
+ async buildUnrestrictAccountTx(params) {
165
+ return this.rpc('buildUnrestrictAccountTx', [omitUndefined({
166
+ ...builderBase(params),
167
+ account: address(params.account),
168
+ restriction_id: restrictionIdParam(params.restrictionId),
169
+ lift_reason: params.liftReason,
170
+ })]);
171
+ }
172
+ async buildRestrictAccountAssetTx(params) {
173
+ return this.rpc('buildRestrictAccountAssetTx', [omitUndefined({
174
+ ...restrictCommon(params),
175
+ account: address(params.account),
176
+ asset: asset(params.asset),
177
+ mode: params.mode,
178
+ })]);
179
+ }
180
+ async buildUnrestrictAccountAssetTx(params) {
181
+ return this.rpc('buildUnrestrictAccountAssetTx', [omitUndefined({
182
+ ...builderBase(params),
183
+ account: address(params.account),
184
+ asset: asset(params.asset),
185
+ restriction_id: restrictionIdParam(params.restrictionId),
186
+ lift_reason: params.liftReason,
187
+ })]);
188
+ }
189
+ async buildSetFrozenAssetAmountTx(params) {
190
+ return this.rpc('buildSetFrozenAssetAmountTx', [omitUndefined({
191
+ ...restrictCommon(params),
192
+ account: address(params.account),
193
+ asset: asset(params.asset),
194
+ amount: u64(params.amount, 'amount'),
195
+ })]);
196
+ }
197
+ async buildSuspendContractTx(params) {
198
+ return this.rpc('buildSuspendContractTx', [omitUndefined({
199
+ ...restrictCommon(params),
200
+ contract: address(params.contract),
201
+ })]);
202
+ }
203
+ async buildResumeContractTx(params) {
204
+ return this.rpc('buildResumeContractTx', [omitUndefined({
205
+ ...builderBase(params),
206
+ contract: address(params.contract),
207
+ restriction_id: restrictionIdParam(params.restrictionId),
208
+ lift_reason: params.liftReason,
209
+ })]);
210
+ }
211
+ async buildQuarantineContractTx(params) {
212
+ return this.rpc('buildQuarantineContractTx', [omitUndefined({
213
+ ...restrictCommon(params),
214
+ contract: address(params.contract),
215
+ })]);
216
+ }
217
+ async buildTerminateContractTx(params) {
218
+ return this.rpc('buildTerminateContractTx', [omitUndefined({
219
+ ...restrictCommon(params),
220
+ contract: address(params.contract),
221
+ })]);
222
+ }
223
+ async buildBanCodeHashTx(params) {
224
+ return this.rpc('buildBanCodeHashTx', [omitUndefined({
225
+ ...restrictCommon(params),
226
+ code_hash: params.codeHash,
227
+ })]);
228
+ }
229
+ async buildUnbanCodeHashTx(params) {
230
+ return this.rpc('buildUnbanCodeHashTx', [omitUndefined({
231
+ ...builderBase(params),
232
+ code_hash: params.codeHash,
233
+ restriction_id: restrictionIdParam(params.restrictionId),
234
+ lift_reason: params.liftReason,
235
+ })]);
236
+ }
237
+ async buildPauseBridgeRouteTx(params) {
238
+ return this.rpc('buildPauseBridgeRouteTx', [omitUndefined({
239
+ ...restrictCommon(params),
240
+ chain: params.chain,
241
+ asset: params.asset,
242
+ })]);
243
+ }
244
+ async buildResumeBridgeRouteTx(params) {
245
+ return this.rpc('buildResumeBridgeRouteTx', [omitUndefined({
246
+ ...builderBase(params),
247
+ chain: params.chain,
248
+ asset: params.asset,
249
+ restriction_id: restrictionIdParam(params.restrictionId),
250
+ lift_reason: params.liftReason,
251
+ })]);
252
+ }
253
+ async buildExtendRestrictionTx(params) {
254
+ return this.rpc('buildExtendRestrictionTx', [omitUndefined({
255
+ ...builderBase(params),
256
+ restriction_id: u64(params.restrictionId, 'restrictionId'),
257
+ new_expires_at_slot: optionalU64(params.newExpiresAtSlot, 'newExpiresAtSlot'),
258
+ evidence_hash: params.evidenceHash,
259
+ })]);
260
+ }
261
+ async buildLiftRestrictionTx(params) {
262
+ return this.rpc('buildLiftRestrictionTx', [omitUndefined({
263
+ ...builderBase(params),
264
+ restriction_id: u64(params.restrictionId, 'restrictionId'),
265
+ lift_reason: params.liftReason,
266
+ })]);
267
+ }
268
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobstercove/lichen-sdk",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Official JavaScript/TypeScript SDK for Lichen blockchain",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -19,7 +19,8 @@
19
19
  "scripts": {
20
20
  "build": "tsc",
21
21
  "dev": "tsc --watch",
22
- "test": "tsc --noEmit",
22
+ "test": "tsc --noEmit && tsc -p tsconfig.test.json --noEmit && npm run test:restrictions",
23
+ "test:restrictions": "npm run build && node test_restrictions_client.js",
23
24
  "prepare": "npm run build"
24
25
  },
25
26
  "keywords": [
@@ -51,6 +52,6 @@
51
52
  "dependencies": {
52
53
  "@noble/post-quantum": "^0.6.0",
53
54
  "bs58": "^5.0.0",
54
- "ws": "^8.16.0"
55
+ "ws": "^8.20.1"
55
56
  }
56
57
  }