@ghostspeak/sdk 1.6.1 → 1.6.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/.tsbuildinfo +1 -1
- package/dist/index.d.ts +257 -97
- package/dist/index.js +154 -38
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -21031,11 +21031,13 @@ var SimpleRpcClient = class {
|
|
|
21031
21031
|
rpc;
|
|
21032
21032
|
rpcSubscriptions;
|
|
21033
21033
|
commitment;
|
|
21034
|
+
endpoint;
|
|
21034
21035
|
constructor(config) {
|
|
21035
|
-
this.
|
|
21036
|
+
this.endpoint = config.endpoint;
|
|
21037
|
+
this.rpc = createSolanaRpc(config.endpoint);
|
|
21036
21038
|
this.commitment = config.commitment ?? "confirmed";
|
|
21037
21039
|
if (config.wsEndpoint) {
|
|
21038
|
-
this.rpcSubscriptions = createSolanaRpcSubscriptions(
|
|
21040
|
+
this.rpcSubscriptions = createSolanaRpcSubscriptions(config.wsEndpoint);
|
|
21039
21041
|
}
|
|
21040
21042
|
}
|
|
21041
21043
|
/**
|
|
@@ -21108,7 +21110,9 @@ var SimpleRpcClient = class {
|
|
|
21108
21110
|
async simulateTransaction(transaction, options) {
|
|
21109
21111
|
return this.rpc.simulateTransaction(transaction, {
|
|
21110
21112
|
commitment: options?.commitment ?? this.commitment,
|
|
21111
|
-
replaceRecentBlockhash: options?.replaceRecentBlockhash ?? false
|
|
21113
|
+
replaceRecentBlockhash: options?.replaceRecentBlockhash ?? false,
|
|
21114
|
+
sigVerify: false,
|
|
21115
|
+
encoding: "base64"
|
|
21112
21116
|
}).send();
|
|
21113
21117
|
}
|
|
21114
21118
|
/**
|
|
@@ -21119,17 +21123,53 @@ var SimpleRpcClient = class {
|
|
|
21119
21123
|
return Number(result.value ?? 5e3);
|
|
21120
21124
|
}
|
|
21121
21125
|
/**
|
|
21122
|
-
* Get program accounts
|
|
21126
|
+
* Get program accounts
|
|
21123
21127
|
*/
|
|
21124
21128
|
async getProgramAccounts(programId, options) {
|
|
21125
|
-
|
|
21126
|
-
|
|
21129
|
+
try {
|
|
21130
|
+
console.log(`Getting program accounts for program: ${programId}`);
|
|
21131
|
+
console.log(`Options: ${JSON.stringify(options)}`);
|
|
21132
|
+
const rpcOptions = {
|
|
21133
|
+
commitment: options?.commitment ?? this.commitment,
|
|
21134
|
+
...options?.filters && { filters: options.filters }
|
|
21135
|
+
};
|
|
21136
|
+
const requestBody = {
|
|
21137
|
+
jsonrpc: "2.0",
|
|
21138
|
+
id: Math.floor(Math.random() * 1e5),
|
|
21139
|
+
method: "getProgramAccounts",
|
|
21140
|
+
params: [programId, rpcOptions]
|
|
21141
|
+
};
|
|
21142
|
+
const response = await globalThis.fetch(this.endpoint, {
|
|
21143
|
+
method: "POST",
|
|
21144
|
+
headers: { "Content-Type": "application/json" },
|
|
21145
|
+
body: JSON.stringify(requestBody)
|
|
21146
|
+
});
|
|
21147
|
+
if (!response.ok) {
|
|
21148
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
21149
|
+
}
|
|
21150
|
+
const data = await response.json();
|
|
21151
|
+
if (data.error) {
|
|
21152
|
+
throw new Error(`RPC Error: ${data.error.message}`);
|
|
21153
|
+
}
|
|
21154
|
+
const accounts = data.result ?? [];
|
|
21155
|
+
console.log(`Found ${accounts.length} program accounts`);
|
|
21156
|
+
return accounts.map((item) => {
|
|
21157
|
+
return {
|
|
21158
|
+
pubkey: item.pubkey,
|
|
21159
|
+
account: this.parseAccountInfo(item.account)
|
|
21160
|
+
};
|
|
21161
|
+
});
|
|
21162
|
+
} catch (error) {
|
|
21163
|
+
console.error(`Failed to get program accounts:`, error);
|
|
21164
|
+
throw new Error(`Failed to get program accounts: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
21165
|
+
}
|
|
21127
21166
|
}
|
|
21128
21167
|
parseAccountInfo(accountInfo) {
|
|
21129
21168
|
const account = accountInfo;
|
|
21130
21169
|
return {
|
|
21131
21170
|
executable: account.executable,
|
|
21132
|
-
lamports: account.lamports,
|
|
21171
|
+
lamports: BigInt(account.lamports),
|
|
21172
|
+
// Cast to Lamports branded type
|
|
21133
21173
|
owner: account.owner,
|
|
21134
21174
|
rentEpoch: account.rentEpoch,
|
|
21135
21175
|
data: account.data,
|
|
@@ -21159,7 +21199,7 @@ var BaseInstructions = class {
|
|
|
21159
21199
|
this._rpcClient ??= new SimpleRpcClient({
|
|
21160
21200
|
endpoint: this.config.rpcEndpoint ?? "https://api.devnet.solana.com",
|
|
21161
21201
|
wsEndpoint: this.config.rpcSubscriptions ? void 0 : void 0,
|
|
21162
|
-
//
|
|
21202
|
+
// WebSocket endpoint from config if available
|
|
21163
21203
|
commitment: this.config.commitment ?? "confirmed"
|
|
21164
21204
|
});
|
|
21165
21205
|
return this._rpcClient;
|
|
@@ -21367,9 +21407,9 @@ var BaseInstructions = class {
|
|
|
21367
21407
|
replaceRecentBlockhash: true
|
|
21368
21408
|
});
|
|
21369
21409
|
console.log(`\u2705 Real simulation completed:`);
|
|
21370
|
-
console.log(` Success: ${!simulation.err}`);
|
|
21371
|
-
console.log(` Compute units: ${simulation.unitsConsumed ?? "N/A"}`);
|
|
21372
|
-
console.log(` Logs: ${simulation.logs?.length ?? 0} entries`);
|
|
21410
|
+
console.log(` Success: ${!simulation.value.err}`);
|
|
21411
|
+
console.log(` Compute units: ${simulation.value.unitsConsumed ?? "N/A"}`);
|
|
21412
|
+
console.log(` Logs: ${simulation.value.logs?.length ?? 0} entries`);
|
|
21373
21413
|
return simulation;
|
|
21374
21414
|
} catch (error) {
|
|
21375
21415
|
console.error("\u274C Real simulation failed:", error);
|
|
@@ -21486,9 +21526,44 @@ var BaseInstructions = class {
|
|
|
21486
21526
|
* Centralizes program account scanning pattern
|
|
21487
21527
|
* NOTE: Temporarily simplified due to RPC client complexity
|
|
21488
21528
|
*/
|
|
21489
|
-
async getDecodedProgramAccounts(decoderImportName,
|
|
21490
|
-
|
|
21491
|
-
|
|
21529
|
+
async getDecodedProgramAccounts(decoderImportName, filters = [], commitment = this.commitment) {
|
|
21530
|
+
try {
|
|
21531
|
+
console.log(`Getting program accounts with decoder: ${decoderImportName}`);
|
|
21532
|
+
console.log(`Filters: ${JSON.stringify(filters)}`);
|
|
21533
|
+
console.log(`Commitment: ${commitment}`);
|
|
21534
|
+
const accounts = await this._rpcClient.getProgramAccounts(this.config.programId, {
|
|
21535
|
+
commitment,
|
|
21536
|
+
filters
|
|
21537
|
+
});
|
|
21538
|
+
console.log(`Found ${Array.isArray(accounts) ? accounts.length : 0} program accounts`);
|
|
21539
|
+
try {
|
|
21540
|
+
const generated = await Promise.resolve().then(() => (init_generated(), generated_exports));
|
|
21541
|
+
const decoderGetter = generated[decoderImportName];
|
|
21542
|
+
if (!decoderGetter || typeof decoderGetter !== "function") {
|
|
21543
|
+
console.warn(`Decoder ${decoderImportName} not found in generated decoders`);
|
|
21544
|
+
return [];
|
|
21545
|
+
}
|
|
21546
|
+
const decoder = decoderGetter();
|
|
21547
|
+
const decodedAccounts = [];
|
|
21548
|
+
for (const { pubkey, account } of accounts) {
|
|
21549
|
+
try {
|
|
21550
|
+
const rawData = Buffer.isBuffer(account.data) || account.data instanceof Uint8Array ? account.data : Buffer.from(account.data.data ?? account.data, "base64");
|
|
21551
|
+
const decodedData = decoder.decode(rawData);
|
|
21552
|
+
decodedAccounts.push({ address: pubkey, data: decodedData });
|
|
21553
|
+
} catch (decodeError) {
|
|
21554
|
+
console.warn(`Failed to decode account ${pubkey}:`, decodeError);
|
|
21555
|
+
}
|
|
21556
|
+
}
|
|
21557
|
+
console.log(`Successfully decoded ${decodedAccounts.length}/${accounts.length} program accounts`);
|
|
21558
|
+
return decodedAccounts;
|
|
21559
|
+
} catch (decoderError) {
|
|
21560
|
+
console.warn(`Failed to load decoder ${decoderImportName}:`, decoderError);
|
|
21561
|
+
return [];
|
|
21562
|
+
}
|
|
21563
|
+
} catch (error) {
|
|
21564
|
+
console.error(`Failed to get program accounts:`, error);
|
|
21565
|
+
throw new Error(`Failed to get program accounts: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
21566
|
+
}
|
|
21492
21567
|
}
|
|
21493
21568
|
/**
|
|
21494
21569
|
* Execute a single instruction with standard error handling
|
|
@@ -22004,7 +22079,7 @@ var EscrowInstructions = class extends BaseInstructions {
|
|
|
22004
22079
|
return {
|
|
22005
22080
|
workOrderAddress: params.workOrderAddress,
|
|
22006
22081
|
deliverables: params.deliverables ?? [],
|
|
22007
|
-
ipfsHash: params.ipfsHash ??
|
|
22082
|
+
ipfsHash: params.ipfsHash ?? "",
|
|
22008
22083
|
metadataUri: params.metadataUri ?? `https://ghostspeak.io/delivery/${Date.now()}`,
|
|
22009
22084
|
signer: params.signer
|
|
22010
22085
|
};
|
|
@@ -22053,7 +22128,7 @@ var EscrowInstructions = class extends BaseInstructions {
|
|
|
22053
22128
|
* Cancel escrow and refund to buyer
|
|
22054
22129
|
*/
|
|
22055
22130
|
async cancel(signer, escrowAddress) {
|
|
22056
|
-
console.
|
|
22131
|
+
console.log("Work order cancellation through dispute resolution...");
|
|
22057
22132
|
return this.dispute({ signer, escrowAddress, reason: "Buyer requested cancellation" });
|
|
22058
22133
|
}
|
|
22059
22134
|
/**
|
|
@@ -22088,8 +22163,8 @@ var EscrowInstructions = class extends BaseInstructions {
|
|
|
22088
22163
|
"dispute filing"
|
|
22089
22164
|
);
|
|
22090
22165
|
} catch (error) {
|
|
22091
|
-
console.
|
|
22092
|
-
|
|
22166
|
+
console.error("Dispute filing failed:", error);
|
|
22167
|
+
throw error;
|
|
22093
22168
|
}
|
|
22094
22169
|
}
|
|
22095
22170
|
/**
|
|
@@ -23211,8 +23286,8 @@ var DisputeInstructions = class extends BaseInstructions {
|
|
|
23211
23286
|
}
|
|
23212
23287
|
}
|
|
23213
23288
|
async deriveUserRegistry(user) {
|
|
23214
|
-
|
|
23215
|
-
return
|
|
23289
|
+
const { deriveUserRegistryPda: deriveUserRegistryPda2 } = await Promise.resolve().then(() => (init_pda(), pda_exports));
|
|
23290
|
+
return deriveUserRegistryPda2(this.config.programId, user.address);
|
|
23216
23291
|
}
|
|
23217
23292
|
disputeToSummary(disputeAddress, dispute) {
|
|
23218
23293
|
const now = BigInt(Math.floor(Date.now() / 1e3));
|
|
@@ -23861,8 +23936,8 @@ var BulkDealsInstructions = class extends BaseInstructions {
|
|
|
23861
23936
|
return null;
|
|
23862
23937
|
}
|
|
23863
23938
|
async deriveUserRegistry(user) {
|
|
23864
|
-
|
|
23865
|
-
return
|
|
23939
|
+
const { deriveUserRegistryPda: deriveUserRegistryPda2 } = await Promise.resolve().then(() => (init_pda(), pda_exports));
|
|
23940
|
+
return deriveUserRegistryPda2(this.config.programId, user.address);
|
|
23866
23941
|
}
|
|
23867
23942
|
};
|
|
23868
23943
|
|
|
@@ -24286,11 +24361,13 @@ var AnalyticsInstructions = class extends BaseInstructions {
|
|
|
24286
24361
|
return 3 /* Unknown */;
|
|
24287
24362
|
}
|
|
24288
24363
|
async deriveUserRegistry(user) {
|
|
24289
|
-
|
|
24290
|
-
return
|
|
24364
|
+
const { deriveUserRegistryPda: deriveUserRegistryPda2 } = await Promise.resolve().then(() => (init_pda(), pda_exports));
|
|
24365
|
+
return deriveUserRegistryPda2(this.config.programId, user.address);
|
|
24291
24366
|
}
|
|
24292
24367
|
async deriveMarketAnalyticsPda() {
|
|
24293
|
-
|
|
24368
|
+
const { findProgramDerivedAddress: findProgramDerivedAddress2 } = await Promise.resolve().then(() => (init_pda(), pda_exports));
|
|
24369
|
+
const [address2] = await findProgramDerivedAddress2(["market_analytics"], this.config.programId);
|
|
24370
|
+
return address2;
|
|
24294
24371
|
}
|
|
24295
24372
|
};
|
|
24296
24373
|
|
|
@@ -24415,17 +24492,24 @@ var ComplianceInstructions = class extends BaseInstructions {
|
|
|
24415
24492
|
console.log(` Verification Level: ${params.verificationLevel}`);
|
|
24416
24493
|
console.log(` Jurisdiction: ${params.jurisdiction}`);
|
|
24417
24494
|
this.validateKycParams(params);
|
|
24418
|
-
|
|
24419
|
-
|
|
24420
|
-
|
|
24421
|
-
|
|
24422
|
-
|
|
24423
|
-
|
|
24424
|
-
|
|
24425
|
-
|
|
24426
|
-
|
|
24427
|
-
|
|
24428
|
-
|
|
24495
|
+
try {
|
|
24496
|
+
await this.deriveAuditTrailPda();
|
|
24497
|
+
const verificationResult = {
|
|
24498
|
+
status: "Pending",
|
|
24499
|
+
// Real KYC requires external verification
|
|
24500
|
+
riskScore: this.calculateKycRiskScore(params),
|
|
24501
|
+
documentVerified: false,
|
|
24502
|
+
// Requires external document verification service
|
|
24503
|
+
biometricMatched: false
|
|
24504
|
+
// Requires biometric verification service
|
|
24505
|
+
};
|
|
24506
|
+
console.log(`\u2705 KYC verification initiated: ${verificationResult.status}`);
|
|
24507
|
+
console.log("Note: External KYC provider integration required for completion");
|
|
24508
|
+
throw new Error("KYC verification requires integration with external compliance providers");
|
|
24509
|
+
} catch (error) {
|
|
24510
|
+
console.error("KYC verification failed:", error);
|
|
24511
|
+
throw error;
|
|
24512
|
+
}
|
|
24429
24513
|
}
|
|
24430
24514
|
/**
|
|
24431
24515
|
* Perform AML screening for transaction
|
|
@@ -24494,7 +24578,8 @@ var ComplianceInstructions = class extends BaseInstructions {
|
|
|
24494
24578
|
requestId,
|
|
24495
24579
|
status: "received",
|
|
24496
24580
|
estimatedCompletion,
|
|
24497
|
-
dataPackage: requestType === "access" ?
|
|
24581
|
+
dataPackage: requestType === "access" ? void 0 : void 0
|
|
24582
|
+
// Data package would be generated by real data collection system
|
|
24498
24583
|
};
|
|
24499
24584
|
}
|
|
24500
24585
|
// =====================================================
|
|
@@ -24605,8 +24690,39 @@ var ComplianceInstructions = class extends BaseInstructions {
|
|
|
24605
24690
|
throw new Error("Transaction amount must be greater than 0");
|
|
24606
24691
|
}
|
|
24607
24692
|
}
|
|
24693
|
+
calculateKycRiskScore(params) {
|
|
24694
|
+
let riskScore = 0;
|
|
24695
|
+
switch (params.verificationLevel) {
|
|
24696
|
+
case "Basic":
|
|
24697
|
+
riskScore += 30;
|
|
24698
|
+
break;
|
|
24699
|
+
case "Enhanced":
|
|
24700
|
+
riskScore += 15;
|
|
24701
|
+
break;
|
|
24702
|
+
case "Premium":
|
|
24703
|
+
riskScore += 5;
|
|
24704
|
+
break;
|
|
24705
|
+
}
|
|
24706
|
+
switch (params.documentType) {
|
|
24707
|
+
case "passport":
|
|
24708
|
+
riskScore += 5;
|
|
24709
|
+
break;
|
|
24710
|
+
case "drivers_license":
|
|
24711
|
+
riskScore += 10;
|
|
24712
|
+
break;
|
|
24713
|
+
case "national_id":
|
|
24714
|
+
riskScore += 8;
|
|
24715
|
+
break;
|
|
24716
|
+
case "utility_bill":
|
|
24717
|
+
riskScore += 20;
|
|
24718
|
+
break;
|
|
24719
|
+
}
|
|
24720
|
+
return Math.min(riskScore, 100);
|
|
24721
|
+
}
|
|
24608
24722
|
async deriveAuditTrailPda() {
|
|
24609
|
-
|
|
24723
|
+
const { findProgramDerivedAddress: findProgramDerivedAddress2 } = await Promise.resolve().then(() => (init_pda(), pda_exports));
|
|
24724
|
+
const [address2] = await findProgramDerivedAddress2(["audit_trail"], this.config.programId);
|
|
24725
|
+
return address2;
|
|
24610
24726
|
}
|
|
24611
24727
|
};
|
|
24612
24728
|
|