@ghostspeak/sdk 2.0.0 → 2.0.1
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/LICENSE +21 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/GhostSpeakClient-CyeZ6Tyb.d.ts +2061 -0
- package/dist/client.d.ts +4 -3
- package/dist/crypto.d.ts +2 -2
- package/dist/{feature-flags-CEaxXgQQ.d.ts → feature-flags-3POmoO_Z.d.ts} +833 -1190
- package/dist/index.d.ts +206 -4543
- package/dist/ipfs-types-KJcvy9Qk.d.ts +553 -0
- package/dist/minimal/core-minimal.d.ts +2037 -82
- package/dist/utils.d.ts +4 -4
- package/package.json +5 -29
- package/dist/EscrowInstructions-4P3H6ETO.js +0 -2
- package/dist/EscrowInstructions-4P3H6ETO.js.map +0 -1
- package/dist/GhostSpeakClient-4SROinEf.d.ts +0 -503
- package/dist/accounts-IUZMPYVE.js +0 -2
- package/dist/accounts-IUZMPYVE.js.map +0 -1
- package/dist/agent-GZ2OES75.js +0 -2
- package/dist/agent-GZ2OES75.js.map +0 -1
- package/dist/auctionMarketplace-W4YM7HKU.js +0 -2
- package/dist/auctionMarketplace-W4YM7HKU.js.map +0 -1
- package/dist/chunk-2KOOI5BX.js +0 -2
- package/dist/chunk-2KOOI5BX.js.map +0 -1
- package/dist/chunk-32GWTXRJ.js +0 -3
- package/dist/chunk-32GWTXRJ.js.map +0 -1
- package/dist/chunk-B4WUFVLE.js +0 -2
- package/dist/chunk-B4WUFVLE.js.map +0 -1
- package/dist/chunk-C2OTQ5YS.js +0 -2
- package/dist/chunk-C2OTQ5YS.js.map +0 -1
- package/dist/chunk-CTC4ZJ26.js +0 -5
- package/dist/chunk-CTC4ZJ26.js.map +0 -1
- package/dist/chunk-DF7LLAMH.js +0 -2
- package/dist/chunk-DF7LLAMH.js.map +0 -1
- package/dist/chunk-DJ356OUX.js +0 -2
- package/dist/chunk-DJ356OUX.js.map +0 -1
- package/dist/chunk-DK5YDBXR.js +0 -2
- package/dist/chunk-DK5YDBXR.js.map +0 -1
- package/dist/chunk-DOTF5ECA.js +0 -4
- package/dist/chunk-DOTF5ECA.js.map +0 -1
- package/dist/chunk-FKEUXXZS.js +0 -30
- package/dist/chunk-FKEUXXZS.js.map +0 -1
- package/dist/chunk-GSHXEKBW.js +0 -2
- package/dist/chunk-GSHXEKBW.js.map +0 -1
- package/dist/chunk-IZDAEOLH.js +0 -2
- package/dist/chunk-IZDAEOLH.js.map +0 -1
- package/dist/chunk-JY554RGE.js +0 -3
- package/dist/chunk-JY554RGE.js.map +0 -1
- package/dist/chunk-KK3HV2RD.js +0 -3
- package/dist/chunk-KK3HV2RD.js.map +0 -1
- package/dist/chunk-PPOCDM6G.js +0 -2
- package/dist/chunk-PPOCDM6G.js.map +0 -1
- package/dist/chunk-PUI35LBF.js +0 -2
- package/dist/chunk-PUI35LBF.js.map +0 -1
- package/dist/chunk-Q34J6YDA.js +0 -11
- package/dist/chunk-Q34J6YDA.js.map +0 -1
- package/dist/chunk-QATBFZMM.js +0 -3
- package/dist/chunk-QATBFZMM.js.map +0 -1
- package/dist/chunk-QTKN3VZV.js +0 -2
- package/dist/chunk-QTKN3VZV.js.map +0 -1
- package/dist/chunk-RFBYMTTN.js +0 -2
- package/dist/chunk-RFBYMTTN.js.map +0 -1
- package/dist/chunk-RJJPOLCK.js +0 -22
- package/dist/chunk-RJJPOLCK.js.map +0 -1
- package/dist/chunk-RTWJTEND.js +0 -2
- package/dist/chunk-RTWJTEND.js.map +0 -1
- package/dist/chunk-SR3ZJCME.js +0 -2
- package/dist/chunk-SR3ZJCME.js.map +0 -1
- package/dist/chunk-TAWXH7KX.js +0 -2
- package/dist/chunk-TAWXH7KX.js.map +0 -1
- package/dist/client.js +0 -2
- package/dist/client.js.map +0 -1
- package/dist/confidential-transfer-manager-CGS3T5DG.js +0 -2
- package/dist/confidential-transfer-manager-CGS3T5DG.js.map +0 -1
- package/dist/crypto.js +0 -2
- package/dist/crypto.js.map +0 -1
- package/dist/elgamal-3ABOJSHC.js +0 -2
- package/dist/elgamal-3ABOJSHC.js.map +0 -1
- package/dist/enhanced-client-errors-W22U3LNH.js +0 -2
- package/dist/enhanced-client-errors-W22U3LNH.js.map +0 -1
- package/dist/errors.js +0 -2
- package/dist/errors.js.map +0 -1
- package/dist/generated-U3L4KUE4.js +0 -2
- package/dist/generated-U3L4KUE4.js.map +0 -1
- package/dist/ghostspeak_wasm-3KPNJTSS.js +0 -2
- package/dist/ghostspeak_wasm-3KPNJTSS.js.map +0 -1
- package/dist/index.js +0 -97
- package/dist/index.js.map +0 -1
- package/dist/ipfs-types-BlxtJ3q2.d.ts +0 -194
- package/dist/metafile-esm.json +0 -1
- package/dist/minimal/core-minimal.js +0 -12
- package/dist/minimal/core-minimal.js.map +0 -1
- package/dist/pda-2GUWRQ5G.js +0 -2
- package/dist/pda-2GUWRQ5G.js.map +0 -1
- package/dist/registerAgentCompressed-L6ACXD2Z.js +0 -2
- package/dist/registerAgentCompressed-L6ACXD2Z.js.map +0 -1
- package/dist/token-2022-rpc-SRHRFN5Y.js +0 -2
- package/dist/token-2022-rpc-SRHRFN5Y.js.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/utils.js +0 -2
- package/dist/utils.js.map +0 -1
- package/dist/zk-proof-builder-GXZ42QZA.js +0 -2
- package/dist/zk-proof-builder-GXZ42QZA.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Address as Address$1 } from '@solana/addresses';
|
|
2
1
|
import { Option, Address, ReadonlyUint8Array, EncodedAccount, MaybeEncodedAccount, fetchEncodedAccount, IInstruction, TransactionSigner } from '@solana/kit';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { Address as Address$1 } from '@solana/addresses';
|
|
3
|
+
import { E as ExecutionCondition, G as GovernanceProposal, j as VotingResults, Q as QuorumRequirements, V as VoteChoice, I as IPFSConfig, a as IPFSUploadOptions, c as IPFSOperationResult, f as IPFSUploadResult, g as IPFSRetrievalOptions, h as IPFSRetrievalResult, i as IPFSPinResult, b as IPFSContentMetadata, C as ContentStorageResult } from './ipfs-types-KJcvy9Qk.js';
|
|
4
|
+
import { Rpc, GetAccountInfoApi } from '@solana/rpc';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* This code was AUTOGENERATED using the codama library.
|
|
@@ -343,24 +343,6 @@ type CompliancePolicies = {
|
|
|
343
343
|
reportingRequirements: Array<string>;
|
|
344
344
|
};
|
|
345
345
|
|
|
346
|
-
/**
|
|
347
|
-
* This code was AUTOGENERATED using the codama library.
|
|
348
|
-
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
349
|
-
* to add features, then rerun codama to update it.
|
|
350
|
-
*
|
|
351
|
-
* @see https://github.com/codama-idl/codama
|
|
352
|
-
*/
|
|
353
|
-
|
|
354
|
-
/** Types of execution conditions */
|
|
355
|
-
declare enum ConditionType {
|
|
356
|
-
TimeDelay = 0,
|
|
357
|
-
TokenBalance = 1,
|
|
358
|
-
PriceThreshold = 2,
|
|
359
|
-
VoteCount = 3,
|
|
360
|
-
ExternalOracle = 4,
|
|
361
|
-
CustomLogic = 5
|
|
362
|
-
}
|
|
363
|
-
|
|
364
346
|
/**
|
|
365
347
|
* This code was AUTOGENERATED using the codama library.
|
|
366
348
|
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
@@ -452,46 +434,6 @@ declare enum DegradationHandling {
|
|
|
452
434
|
AdaptiveThreshold = 3
|
|
453
435
|
}
|
|
454
436
|
|
|
455
|
-
/**
|
|
456
|
-
* This code was AUTOGENERATED using the codama library.
|
|
457
|
-
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
458
|
-
* to add features, then rerun codama to update it.
|
|
459
|
-
*
|
|
460
|
-
* @see https://github.com/codama-idl/codama
|
|
461
|
-
*/
|
|
462
|
-
|
|
463
|
-
/** Vote delegation information */
|
|
464
|
-
type DelegationInfo = {
|
|
465
|
-
/** Original delegator */
|
|
466
|
-
delegator: Address;
|
|
467
|
-
/** Delegation timestamp */
|
|
468
|
-
delegatedAt: bigint;
|
|
469
|
-
/** Delegation scope */
|
|
470
|
-
scope: DelegationScope;
|
|
471
|
-
/** Delegation expiry */
|
|
472
|
-
expiresAt: Option<bigint>;
|
|
473
|
-
};
|
|
474
|
-
|
|
475
|
-
/**
|
|
476
|
-
* This code was AUTOGENERATED using the codama library.
|
|
477
|
-
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
478
|
-
* to add features, then rerun codama to update it.
|
|
479
|
-
*
|
|
480
|
-
* @see https://github.com/codama-idl/codama
|
|
481
|
-
*/
|
|
482
|
-
|
|
483
|
-
/** Scope of vote delegation */
|
|
484
|
-
type DelegationScope = {
|
|
485
|
-
__kind: 'All';
|
|
486
|
-
} | {
|
|
487
|
-
__kind: 'ProposalType';
|
|
488
|
-
fields: readonly [ProposalType];
|
|
489
|
-
} | {
|
|
490
|
-
__kind: 'SingleProposal';
|
|
491
|
-
} | {
|
|
492
|
-
__kind: 'Limited';
|
|
493
|
-
};
|
|
494
|
-
|
|
495
437
|
/**
|
|
496
438
|
* This code was AUTOGENERATED using the codama library.
|
|
497
439
|
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
@@ -550,52 +492,6 @@ declare enum EnforcementLevel {
|
|
|
550
492
|
ExceptionBased = 3
|
|
551
493
|
}
|
|
552
494
|
|
|
553
|
-
/**
|
|
554
|
-
* This code was AUTOGENERATED using the codama library.
|
|
555
|
-
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
556
|
-
* to add features, then rerun codama to update it.
|
|
557
|
-
*
|
|
558
|
-
* @see https://github.com/codama-idl/codama
|
|
559
|
-
*/
|
|
560
|
-
|
|
561
|
-
/** Execution conditions for transactions */
|
|
562
|
-
type ExecutionCondition = {
|
|
563
|
-
/** Condition type */
|
|
564
|
-
conditionType: ConditionType;
|
|
565
|
-
/** Target value/threshold */
|
|
566
|
-
targetValue: bigint;
|
|
567
|
-
/** Current value */
|
|
568
|
-
currentValue: bigint;
|
|
569
|
-
/** Condition met */
|
|
570
|
-
met: boolean;
|
|
571
|
-
/** Condition description */
|
|
572
|
-
description: string;
|
|
573
|
-
};
|
|
574
|
-
|
|
575
|
-
/**
|
|
576
|
-
* This code was AUTOGENERATED using the codama library.
|
|
577
|
-
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
578
|
-
* to add features, then rerun codama to update it.
|
|
579
|
-
*
|
|
580
|
-
* @see https://github.com/codama-idl/codama
|
|
581
|
-
*/
|
|
582
|
-
|
|
583
|
-
/** Execution parameters for proposals */
|
|
584
|
-
type ExecutionParams = {
|
|
585
|
-
/** Instructions to execute if passed */
|
|
586
|
-
instructions: Array<ProposalInstruction>;
|
|
587
|
-
/** Time delay before execution */
|
|
588
|
-
executionDelay: bigint;
|
|
589
|
-
/** Execution conditions */
|
|
590
|
-
executionConditions: Array<ExecutionCondition>;
|
|
591
|
-
/** Can be cancelled after approval */
|
|
592
|
-
cancellable: boolean;
|
|
593
|
-
/** Automatic execution enabled */
|
|
594
|
-
autoExecute: boolean;
|
|
595
|
-
/** Required execution authority */
|
|
596
|
-
executionAuthority: Address;
|
|
597
|
-
};
|
|
598
|
-
|
|
599
495
|
/**
|
|
600
496
|
* This code was AUTOGENERATED using the codama library.
|
|
601
497
|
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
@@ -1126,148 +1022,6 @@ declare enum PolicyType {
|
|
|
1126
1022
|
Emergency = 5
|
|
1127
1023
|
}
|
|
1128
1024
|
|
|
1129
|
-
/**
|
|
1130
|
-
* This code was AUTOGENERATED using the codama library.
|
|
1131
|
-
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
1132
|
-
* to add features, then rerun codama to update it.
|
|
1133
|
-
*
|
|
1134
|
-
* @see https://github.com/codama-idl/codama
|
|
1135
|
-
*/
|
|
1136
|
-
|
|
1137
|
-
/** Account specification for proposal instruction */
|
|
1138
|
-
type ProposalAccount = {
|
|
1139
|
-
/** Account public key */
|
|
1140
|
-
pubkey: Address;
|
|
1141
|
-
/** Is signer required */
|
|
1142
|
-
isSigner: boolean;
|
|
1143
|
-
/** Is writable */
|
|
1144
|
-
isWritable: boolean;
|
|
1145
|
-
/** Account description */
|
|
1146
|
-
description: string;
|
|
1147
|
-
};
|
|
1148
|
-
|
|
1149
|
-
/**
|
|
1150
|
-
* This code was AUTOGENERATED using the codama library.
|
|
1151
|
-
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
1152
|
-
* to add features, then rerun codama to update it.
|
|
1153
|
-
*
|
|
1154
|
-
* @see https://github.com/codama-idl/codama
|
|
1155
|
-
*/
|
|
1156
|
-
|
|
1157
|
-
/** Individual instruction in proposal */
|
|
1158
|
-
type ProposalInstruction = {
|
|
1159
|
-
/** Target program */
|
|
1160
|
-
programId: Address;
|
|
1161
|
-
/** Accounts required */
|
|
1162
|
-
accounts: Array<ProposalAccount>;
|
|
1163
|
-
/** Instruction data */
|
|
1164
|
-
data: ReadonlyUint8Array;
|
|
1165
|
-
/** Instruction description */
|
|
1166
|
-
description: string;
|
|
1167
|
-
};
|
|
1168
|
-
|
|
1169
|
-
/**
|
|
1170
|
-
* This code was AUTOGENERATED using the codama library.
|
|
1171
|
-
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
1172
|
-
* to add features, then rerun codama to update it.
|
|
1173
|
-
*
|
|
1174
|
-
* @see https://github.com/codama-idl/codama
|
|
1175
|
-
*/
|
|
1176
|
-
|
|
1177
|
-
/** Proposal metadata */
|
|
1178
|
-
type ProposalMetadata = {
|
|
1179
|
-
/** IPFS hash for detailed proposal */
|
|
1180
|
-
ipfsHash: Option<string>;
|
|
1181
|
-
/** External references */
|
|
1182
|
-
externalReferences: Array<string>;
|
|
1183
|
-
/** Proposal tags */
|
|
1184
|
-
tags: Array<string>;
|
|
1185
|
-
/** Risk assessment */
|
|
1186
|
-
riskAssessment: Option<string>;
|
|
1187
|
-
/** Impact analysis */
|
|
1188
|
-
impactAnalysis: Option<string>;
|
|
1189
|
-
/** Implementation timeline */
|
|
1190
|
-
implementationTimeline: Option<string>;
|
|
1191
|
-
};
|
|
1192
|
-
|
|
1193
|
-
/**
|
|
1194
|
-
* This code was AUTOGENERATED using the codama library.
|
|
1195
|
-
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
1196
|
-
* to add features, then rerun codama to update it.
|
|
1197
|
-
*
|
|
1198
|
-
* @see https://github.com/codama-idl/codama
|
|
1199
|
-
*/
|
|
1200
|
-
|
|
1201
|
-
/** Proposal execution status */
|
|
1202
|
-
declare enum ProposalStatus {
|
|
1203
|
-
Draft = 0,
|
|
1204
|
-
Active = 1,
|
|
1205
|
-
Passed = 2,
|
|
1206
|
-
Failed = 3,
|
|
1207
|
-
Executed = 4,
|
|
1208
|
-
Cancelled = 5,
|
|
1209
|
-
Expired = 6,
|
|
1210
|
-
Queued = 7
|
|
1211
|
-
}
|
|
1212
|
-
|
|
1213
|
-
/**
|
|
1214
|
-
* This code was AUTOGENERATED using the codama library.
|
|
1215
|
-
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
1216
|
-
* to add features, then rerun codama to update it.
|
|
1217
|
-
*
|
|
1218
|
-
* @see https://github.com/codama-idl/codama
|
|
1219
|
-
*/
|
|
1220
|
-
|
|
1221
|
-
/** Types of governance proposals */
|
|
1222
|
-
declare enum ProposalType {
|
|
1223
|
-
ParameterUpdate = 0,
|
|
1224
|
-
ProtocolUpgrade = 1,
|
|
1225
|
-
TreasuryOperation = 2,
|
|
1226
|
-
FeeUpdate = 3,
|
|
1227
|
-
SecurityUpdate = 4,
|
|
1228
|
-
GovernanceUpdate = 5,
|
|
1229
|
-
EmergencyAction = 6,
|
|
1230
|
-
Custom = 7
|
|
1231
|
-
}
|
|
1232
|
-
|
|
1233
|
-
/**
|
|
1234
|
-
* This code was AUTOGENERATED using the codama library.
|
|
1235
|
-
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
1236
|
-
* to add features, then rerun codama to update it.
|
|
1237
|
-
*
|
|
1238
|
-
* @see https://github.com/codama-idl/codama
|
|
1239
|
-
*/
|
|
1240
|
-
|
|
1241
|
-
/** Methods for calculating quorum */
|
|
1242
|
-
declare enum QuorumMethod {
|
|
1243
|
-
Absolute = 0,
|
|
1244
|
-
Relative = 1,
|
|
1245
|
-
Weighted = 2,
|
|
1246
|
-
Dynamic = 3
|
|
1247
|
-
}
|
|
1248
|
-
|
|
1249
|
-
/**
|
|
1250
|
-
* This code was AUTOGENERATED using the codama library.
|
|
1251
|
-
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
1252
|
-
* to add features, then rerun codama to update it.
|
|
1253
|
-
*
|
|
1254
|
-
* @see https://github.com/codama-idl/codama
|
|
1255
|
-
*/
|
|
1256
|
-
|
|
1257
|
-
/** Quorum requirements for proposals */
|
|
1258
|
-
type QuorumRequirements = {
|
|
1259
|
-
/** Minimum participation rate (0-100) */
|
|
1260
|
-
minimumParticipation: number;
|
|
1261
|
-
/** Approval threshold (0-100) */
|
|
1262
|
-
approvalThreshold: number;
|
|
1263
|
-
/** Super majority required */
|
|
1264
|
-
superMajorityRequired: boolean;
|
|
1265
|
-
/** Minimum total voting power */
|
|
1266
|
-
minimumVotingPower: bigint;
|
|
1267
|
-
/** Quorum calculation method */
|
|
1268
|
-
quorumMethod: QuorumMethod;
|
|
1269
|
-
};
|
|
1270
|
-
|
|
1271
1025
|
/**
|
|
1272
1026
|
* This code was AUTOGENERATED using the codama library.
|
|
1273
1027
|
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
@@ -1921,117 +1675,6 @@ declare enum ValueType {
|
|
|
1921
1675
|
Object = 7
|
|
1922
1676
|
}
|
|
1923
1677
|
|
|
1924
|
-
/**
|
|
1925
|
-
* This code was AUTOGENERATED using the codama library.
|
|
1926
|
-
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
1927
|
-
* to add features, then rerun codama to update it.
|
|
1928
|
-
*
|
|
1929
|
-
* @see https://github.com/codama-idl/codama
|
|
1930
|
-
*/
|
|
1931
|
-
|
|
1932
|
-
/** Individual vote record */
|
|
1933
|
-
type Vote = {
|
|
1934
|
-
/** Voter public key */
|
|
1935
|
-
voter: Address;
|
|
1936
|
-
/** Vote choice */
|
|
1937
|
-
choice: VoteChoice;
|
|
1938
|
-
/** Voting power used */
|
|
1939
|
-
votingPower: bigint;
|
|
1940
|
-
/** Vote timestamp */
|
|
1941
|
-
votedAt: bigint;
|
|
1942
|
-
/** Vote reasoning (optional) */
|
|
1943
|
-
reasoning: Option<string>;
|
|
1944
|
-
/** Delegation info (if delegated vote) */
|
|
1945
|
-
delegationInfo: Option<DelegationInfo>;
|
|
1946
|
-
};
|
|
1947
|
-
|
|
1948
|
-
/**
|
|
1949
|
-
* This code was AUTOGENERATED using the codama library.
|
|
1950
|
-
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
1951
|
-
* to add features, then rerun codama to update it.
|
|
1952
|
-
*
|
|
1953
|
-
* @see https://github.com/codama-idl/codama
|
|
1954
|
-
*/
|
|
1955
|
-
|
|
1956
|
-
/** Vote choices */
|
|
1957
|
-
declare enum VoteChoice {
|
|
1958
|
-
For = 0,
|
|
1959
|
-
Against = 1,
|
|
1960
|
-
Abstain = 2
|
|
1961
|
-
}
|
|
1962
|
-
|
|
1963
|
-
/**
|
|
1964
|
-
* This code was AUTOGENERATED using the codama library.
|
|
1965
|
-
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
1966
|
-
* to add features, then rerun codama to update it.
|
|
1967
|
-
*
|
|
1968
|
-
* @see https://github.com/codama-idl/codama
|
|
1969
|
-
*/
|
|
1970
|
-
|
|
1971
|
-
/** Voting results for proposal */
|
|
1972
|
-
type VotingResults = {
|
|
1973
|
-
/** Total votes for */
|
|
1974
|
-
votesFor: bigint;
|
|
1975
|
-
/** Total votes against */
|
|
1976
|
-
votesAgainst: bigint;
|
|
1977
|
-
/** Total votes abstain */
|
|
1978
|
-
votesAbstain: bigint;
|
|
1979
|
-
/** Total voting power */
|
|
1980
|
-
totalVotingPower: bigint;
|
|
1981
|
-
/** Participation rate */
|
|
1982
|
-
participationRate: number;
|
|
1983
|
-
/** Individual votes */
|
|
1984
|
-
individualVotes: Array<Vote>;
|
|
1985
|
-
/** Weighted voting enabled */
|
|
1986
|
-
weightedVoting: boolean;
|
|
1987
|
-
/** Quorum reached */
|
|
1988
|
-
quorumReached: boolean;
|
|
1989
|
-
/** Approval threshold met */
|
|
1990
|
-
approvalThresholdMet: boolean;
|
|
1991
|
-
};
|
|
1992
|
-
|
|
1993
|
-
/**
|
|
1994
|
-
* This code was AUTOGENERATED using the codama library.
|
|
1995
|
-
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
1996
|
-
* to add features, then rerun codama to update it.
|
|
1997
|
-
*
|
|
1998
|
-
* @see https://github.com/codama-idl/codama
|
|
1999
|
-
*/
|
|
2000
|
-
|
|
2001
|
-
type GovernanceProposal = {
|
|
2002
|
-
discriminator: ReadonlyUint8Array;
|
|
2003
|
-
/** Proposal ID */
|
|
2004
|
-
proposalId: bigint;
|
|
2005
|
-
/** Proposer */
|
|
2006
|
-
proposer: Address;
|
|
2007
|
-
/** Proposal title */
|
|
2008
|
-
title: string;
|
|
2009
|
-
/** Proposal description */
|
|
2010
|
-
description: string;
|
|
2011
|
-
/** Proposal type */
|
|
2012
|
-
proposalType: ProposalType;
|
|
2013
|
-
/** Creation timestamp */
|
|
2014
|
-
createdAt: bigint;
|
|
2015
|
-
/** Voting start timestamp */
|
|
2016
|
-
votingStartsAt: bigint;
|
|
2017
|
-
/** Voting end timestamp */
|
|
2018
|
-
votingEndsAt: bigint;
|
|
2019
|
-
/** Execution timestamp (if approved) */
|
|
2020
|
-
executionTimestamp: Option<bigint>;
|
|
2021
|
-
/** Proposal status */
|
|
2022
|
-
status: ProposalStatus;
|
|
2023
|
-
/** Voting results */
|
|
2024
|
-
votingResults: VotingResults;
|
|
2025
|
-
/** Execution parameters */
|
|
2026
|
-
executionParams: ExecutionParams;
|
|
2027
|
-
/** Quorum requirements */
|
|
2028
|
-
quorumRequirements: QuorumRequirements;
|
|
2029
|
-
/** Proposal metadata */
|
|
2030
|
-
metadata: ProposalMetadata;
|
|
2031
|
-
/** Reserved space */
|
|
2032
|
-
reserved: ReadonlyUint8Array;
|
|
2033
|
-
};
|
|
2034
|
-
|
|
2035
1678
|
/**
|
|
2036
1679
|
* This code was AUTOGENERATED using the codama library.
|
|
2037
1680
|
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
@@ -2101,1051 +1744,1051 @@ type RbacConfig = {
|
|
|
2101
1744
|
};
|
|
2102
1745
|
|
|
2103
1746
|
/**
|
|
2104
|
-
*
|
|
2105
|
-
*/
|
|
2106
|
-
interface TransferProofData {
|
|
2107
|
-
/** The encrypted transfer amount (ElGamal ciphertext) */
|
|
2108
|
-
encryptedTransferAmount: Uint8Array;
|
|
2109
|
-
/** Source account's new encrypted balance commitment */
|
|
2110
|
-
newSourceCommitment: Uint8Array;
|
|
2111
|
-
/** Equality proof for source balance */
|
|
2112
|
-
equalityProof: Uint8Array;
|
|
2113
|
-
/** Validity proof for the transfer */
|
|
2114
|
-
validityProof: Uint8Array;
|
|
2115
|
-
/** Range proof for the transfer amount and remaining balance */
|
|
2116
|
-
rangeProof: Uint8Array;
|
|
2117
|
-
}
|
|
2118
|
-
|
|
2119
|
-
/**
|
|
2120
|
-
* Complete ElGamal Encryption Module with Full ZK Proof Implementation
|
|
2121
|
-
*
|
|
2122
|
-
* This module provides production-ready ElGamal encryption on Curve25519 with
|
|
2123
|
-
* complete zero-knowledge proof generation for Solana's confidential transfers.
|
|
1747
|
+
* Discriminator Validation Utilities
|
|
2124
1748
|
*
|
|
2125
|
-
*
|
|
2126
|
-
*
|
|
2127
|
-
* - Bulletproof range proofs for amounts (0 to 2^64)
|
|
2128
|
-
* - Validity proofs for well-formed ciphertexts
|
|
2129
|
-
* - Equality proofs for value conservation
|
|
2130
|
-
* - Transfer proofs combining all necessary proofs
|
|
2131
|
-
* - Full integration with Solana's ZK ElGamal Proof Program
|
|
1749
|
+
* Handles discriminator validation and provides fallback mechanisms
|
|
1750
|
+
* for accounts with mismatched discriminators
|
|
2132
1751
|
*/
|
|
2133
1752
|
|
|
2134
|
-
interface
|
|
2135
|
-
|
|
2136
|
-
|
|
1753
|
+
interface DiscriminatorValidationResult {
|
|
1754
|
+
isValid: boolean;
|
|
1755
|
+
expectedLength: number;
|
|
1756
|
+
actualLength: number;
|
|
1757
|
+
canDecode: boolean;
|
|
1758
|
+
needsMigration: boolean;
|
|
1759
|
+
errorMessage?: string;
|
|
1760
|
+
}
|
|
1761
|
+
interface AccountInspectionResult {
|
|
1762
|
+
address: string;
|
|
1763
|
+
dataLength: number;
|
|
1764
|
+
discriminator: Uint8Array | null;
|
|
1765
|
+
discriminatorLength: number;
|
|
1766
|
+
isAgentAccount: boolean;
|
|
1767
|
+
needsMigration: boolean;
|
|
1768
|
+
rawData: Uint8Array;
|
|
2137
1769
|
}
|
|
2138
|
-
|
|
2139
1770
|
/**
|
|
2140
|
-
*
|
|
2141
|
-
*
|
|
2142
|
-
* Provides comprehensive token handling utilities including:
|
|
2143
|
-
* - Associated Token Account (ATA) derivation for both SPL Token and Token 2022
|
|
2144
|
-
* - Token 2022 specific features (transfer fees, confidential transfers, etc.)
|
|
2145
|
-
* - Token program detection and validation
|
|
2146
|
-
* - Account creation and management utilities
|
|
2147
|
-
*
|
|
2148
|
-
* Based on the latest SPL Token 2022 specification and @solana/kit v2.3.0
|
|
1771
|
+
* Validates account discriminator before attempting to decode
|
|
2149
1772
|
*/
|
|
2150
|
-
|
|
1773
|
+
declare function validateAccountDiscriminator(accountData: Uint8Array, expectedDiscriminator: Uint8Array): DiscriminatorValidationResult;
|
|
2151
1774
|
/**
|
|
2152
|
-
*
|
|
1775
|
+
* Create user-friendly error message for discriminator issues
|
|
2153
1776
|
*/
|
|
2154
|
-
declare
|
|
2155
|
-
/** Original SPL Token Program */
|
|
2156
|
-
SPL_TOKEN = "spl-token",
|
|
2157
|
-
/** SPL Token 2022 (Token Extensions) Program */
|
|
2158
|
-
TOKEN_2022 = "token-2022"
|
|
2159
|
-
}
|
|
1777
|
+
declare function createDiscriminatorErrorMessage(validation: DiscriminatorValidationResult, accountType: string, address: string): string;
|
|
2160
1778
|
/**
|
|
2161
|
-
*
|
|
1779
|
+
* Safe Agent account decoding with discriminator validation
|
|
1780
|
+
* Returns a compatibility result with exists property
|
|
2162
1781
|
*/
|
|
2163
|
-
|
|
2164
|
-
/** The derived ATA address */
|
|
1782
|
+
declare function safeDecodeAgent(encodedAccount: {
|
|
2165
1783
|
address: Address$1;
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
tokenProgram: Address$1;
|
|
2172
|
-
/** Whether this is a Token 2022 ATA */
|
|
2173
|
-
isToken2022: boolean;
|
|
2174
|
-
}
|
|
1784
|
+
data: Uint8Array;
|
|
1785
|
+
}): Promise<{
|
|
1786
|
+
exists: boolean;
|
|
1787
|
+
data?: unknown;
|
|
1788
|
+
} | null>;
|
|
2175
1789
|
/**
|
|
2176
|
-
*
|
|
2177
|
-
* Based on the latest Token Extensions specification
|
|
1790
|
+
* Inspects account data and extracts useful information about discriminator
|
|
2178
1791
|
*/
|
|
2179
|
-
declare
|
|
2180
|
-
|
|
2181
|
-
UNINITIALIZED = 0,
|
|
2182
|
-
/** Transfer fee extension */
|
|
2183
|
-
TRANSFER_FEE_CONFIG = 1,
|
|
2184
|
-
/** Transfer fee amount */
|
|
2185
|
-
TRANSFER_FEE_AMOUNT = 2,
|
|
2186
|
-
/** Mint close authority */
|
|
2187
|
-
MINT_CLOSE_AUTHORITY = 3,
|
|
2188
|
-
/** Confidential transfer mint */
|
|
2189
|
-
CONFIDENTIAL_TRANSFER_MINT = 4,
|
|
2190
|
-
/** Confidential transfer account */
|
|
2191
|
-
CONFIDENTIAL_TRANSFER_ACCOUNT = 5,
|
|
2192
|
-
/** Default account state */
|
|
2193
|
-
DEFAULT_ACCOUNT_STATE = 6,
|
|
2194
|
-
/** Immutable owner */
|
|
2195
|
-
IMMUTABLE_OWNER = 7,
|
|
2196
|
-
/** Memo transfer */
|
|
2197
|
-
MEMO_TRANSFER = 8,
|
|
2198
|
-
/** Non-transferable */
|
|
2199
|
-
NON_TRANSFERABLE = 9,
|
|
2200
|
-
/** Interest bearing mint */
|
|
2201
|
-
INTEREST_BEARING_MINT = 10,
|
|
2202
|
-
/** CPI guard */
|
|
2203
|
-
CPI_GUARD = 11,
|
|
2204
|
-
/** Permanent delegate */
|
|
2205
|
-
PERMANENT_DELEGATE = 12,
|
|
2206
|
-
/** Non-transferable account */
|
|
2207
|
-
NON_TRANSFERABLE_ACCOUNT = 13,
|
|
2208
|
-
/** Transfer hook */
|
|
2209
|
-
TRANSFER_HOOK = 14,
|
|
2210
|
-
/** Transfer hook account */
|
|
2211
|
-
TRANSFER_HOOK_ACCOUNT = 15,
|
|
2212
|
-
/** Metadata pointer */
|
|
2213
|
-
METADATA_POINTER = 16,
|
|
2214
|
-
/** Token metadata */
|
|
2215
|
-
TOKEN_METADATA = 17,
|
|
2216
|
-
/** Group pointer */
|
|
2217
|
-
GROUP_POINTER = 18,
|
|
2218
|
-
/** Token group */
|
|
2219
|
-
TOKEN_GROUP = 19,
|
|
2220
|
-
/** Group member pointer */
|
|
2221
|
-
GROUP_MEMBER_POINTER = 20,
|
|
2222
|
-
/** Token group member */
|
|
2223
|
-
TOKEN_GROUP_MEMBER = 21
|
|
2224
|
-
}
|
|
1792
|
+
declare function inspectAccountData(encodedAccount: EncodedAccount | MaybeEncodedAccount, address: string): AccountInspectionResult;
|
|
1793
|
+
|
|
2225
1794
|
/**
|
|
2226
|
-
*
|
|
1795
|
+
* Account Migration Utility
|
|
1796
|
+
*
|
|
1797
|
+
* Handles migration of old Agent accounts that were created with
|
|
1798
|
+
* different discriminator formats to the current format.
|
|
2227
1799
|
*/
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
withdrawWithheldAuthority: Address$1 | null;
|
|
2237
|
-
/** Amount of fees currently withheld */
|
|
2238
|
-
withheldAmount: bigint;
|
|
2239
|
-
/** Older transfer fee configuration */
|
|
2240
|
-
olderTransferFee: {
|
|
2241
|
-
epoch: bigint;
|
|
2242
|
-
transferFeeBasisPoints: number;
|
|
2243
|
-
maximumFee: bigint;
|
|
2244
|
-
};
|
|
2245
|
-
/** Newer transfer fee configuration */
|
|
2246
|
-
newerTransferFee: {
|
|
2247
|
-
epoch: bigint;
|
|
2248
|
-
transferFeeBasisPoints: number;
|
|
2249
|
-
maximumFee: bigint;
|
|
2250
|
-
};
|
|
1800
|
+
|
|
1801
|
+
interface MigrationPlan {
|
|
1802
|
+
address: string;
|
|
1803
|
+
currentState: 'valid' | 'needs_migration' | 'invalid' | 'not_exists';
|
|
1804
|
+
migrationType: 'none' | 'recreate' | 'data_conversion' | 'unsupported';
|
|
1805
|
+
issues: string[];
|
|
1806
|
+
recommendations: string[];
|
|
1807
|
+
canAutoMigrate: boolean;
|
|
2251
1808
|
}
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
/** Automatically approve new accounts for confidential transfers */
|
|
2259
|
-
autoApproveNewAccounts: boolean;
|
|
2260
|
-
/** Public key for auditing confidential transfers */
|
|
2261
|
-
auditorElgamalPubkey: Uint8Array | null;
|
|
1809
|
+
interface MigrationResult {
|
|
1810
|
+
success: boolean;
|
|
1811
|
+
address: string;
|
|
1812
|
+
action: 'skipped' | 'migrated' | 'failed';
|
|
1813
|
+
error?: string;
|
|
1814
|
+
newAccountData?: Uint8Array;
|
|
2262
1815
|
}
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
/** Authority that can update the interest rate */
|
|
2268
|
-
rateAuthority: Address$1 | null;
|
|
2269
|
-
/** Current interest rate (basis points per year) */
|
|
2270
|
-
currentRate: number;
|
|
2271
|
-
/** Timestamp when interest bearing was initialized */
|
|
2272
|
-
initializationTimestamp: bigint;
|
|
2273
|
-
/** Timestamp of last rate update */
|
|
2274
|
-
lastUpdateTimestamp: bigint;
|
|
2275
|
-
/** Pre-computed interest rate */
|
|
2276
|
-
preUpdateAverageRate: number;
|
|
1816
|
+
interface LegacyAgentData {
|
|
1817
|
+
discriminator: Uint8Array;
|
|
1818
|
+
owner?: string;
|
|
1819
|
+
name?: string;
|
|
2277
1820
|
}
|
|
2278
1821
|
/**
|
|
2279
|
-
*
|
|
2280
|
-
*
|
|
2281
|
-
* This is the core ATA derivation function that works with both
|
|
2282
|
-
* SPL Token and Token 2022 programs. The derivation follows the
|
|
2283
|
-
* standard pattern: ['owner', 'token_program', 'mint']
|
|
2284
|
-
*
|
|
2285
|
-
* @param owner - The wallet/owner address
|
|
2286
|
-
* @param mint - The token mint address
|
|
2287
|
-
* @param tokenProgram - The token program address (SPL Token or Token 2022)
|
|
2288
|
-
* @returns Promise<Address> - The derived ATA address
|
|
2289
|
-
*/
|
|
2290
|
-
declare function deriveAssociatedTokenAddress(owner: Address$1, mint: Address$1, tokenProgram?: Address$1): Promise<Address$1>;
|
|
2291
|
-
/**
|
|
2292
|
-
* Derive Associated Token Account for SPL Token (legacy)
|
|
2293
|
-
*
|
|
2294
|
-
* @param owner - The wallet/owner address
|
|
2295
|
-
* @param mint - The token mint address
|
|
2296
|
-
* @returns Promise<Address> - The derived ATA address
|
|
2297
|
-
*/
|
|
2298
|
-
declare function deriveSplTokenAssociatedTokenAddress(owner: Address$1, mint: Address$1): Promise<Address$1>;
|
|
2299
|
-
/**
|
|
2300
|
-
* Derive Associated Token Account for Token 2022
|
|
2301
|
-
*
|
|
2302
|
-
* @param owner - The wallet/owner address
|
|
2303
|
-
* @param mint - The token mint address
|
|
2304
|
-
* @returns Promise<Address> - The derived ATA address
|
|
1822
|
+
* Analyzes an account and creates a migration plan
|
|
2305
1823
|
*/
|
|
2306
|
-
declare function
|
|
1824
|
+
declare function createMigrationPlan(encodedAccount: EncodedAccount | MaybeEncodedAccount, address: string): Promise<MigrationPlan>;
|
|
2307
1825
|
/**
|
|
2308
|
-
*
|
|
2309
|
-
*
|
|
2310
|
-
* @param owner - The wallet/owner address
|
|
2311
|
-
* @param mint - The token mint address
|
|
2312
|
-
* @param tokenProgram - Optional: specify token program, auto-detect if not provided
|
|
2313
|
-
* @returns Promise<AssociatedTokenAccount> - Complete ATA information
|
|
1826
|
+
* Attempts to extract meaningful data from a legacy account
|
|
2314
1827
|
*/
|
|
2315
|
-
declare function
|
|
1828
|
+
declare function extractLegacyData(encodedAccount: EncodedAccount | MaybeEncodedAccount): LegacyAgentData | null;
|
|
2316
1829
|
/**
|
|
2317
|
-
*
|
|
2318
|
-
* Note: This requires RPC calls to fetch mint account data
|
|
2319
|
-
*
|
|
2320
|
-
* @param mint - The token mint address
|
|
2321
|
-
* @returns Promise<Address> - The token program address
|
|
1830
|
+
* Creates a detailed migration report for multiple accounts
|
|
2322
1831
|
*/
|
|
2323
|
-
declare function
|
|
1832
|
+
declare function createMigrationReport(accounts: {
|
|
1833
|
+
address: string;
|
|
1834
|
+
encodedAccount: EncodedAccount | MaybeEncodedAccount;
|
|
1835
|
+
}[]): Promise<{
|
|
1836
|
+
summary: {
|
|
1837
|
+
total: number;
|
|
1838
|
+
valid: number;
|
|
1839
|
+
needsMigration: number;
|
|
1840
|
+
invalid: number;
|
|
1841
|
+
canAutoMigrate: number;
|
|
1842
|
+
};
|
|
1843
|
+
plans: MigrationPlan[];
|
|
1844
|
+
recommendations: string[];
|
|
1845
|
+
}>;
|
|
2324
1846
|
/**
|
|
2325
|
-
*
|
|
2326
|
-
*
|
|
2327
|
-
* @param mint - The token mint address
|
|
2328
|
-
* @returns Promise<boolean> - True if Token 2022, false if SPL Token
|
|
1847
|
+
* Simulates migration without actually performing it
|
|
2329
1848
|
*/
|
|
2330
|
-
declare function
|
|
1849
|
+
declare function simulateMigration(encodedAccount: EncodedAccount | MaybeEncodedAccount, address: string): Promise<{
|
|
1850
|
+
plan: MigrationPlan;
|
|
1851
|
+
simulation: {
|
|
1852
|
+
wouldSucceed: boolean;
|
|
1853
|
+
estimatedSteps: string[];
|
|
1854
|
+
warnings: string[];
|
|
1855
|
+
requiredActions: string[];
|
|
1856
|
+
};
|
|
1857
|
+
}>;
|
|
2331
1858
|
/**
|
|
2332
|
-
*
|
|
2333
|
-
*
|
|
2334
|
-
* @param mint - The token mint address
|
|
2335
|
-
* @returns Promise<TokenProgram> - The token program enum
|
|
1859
|
+
* Provides user-friendly migration instructions
|
|
2336
1860
|
*/
|
|
2337
|
-
declare function
|
|
1861
|
+
declare function getMigrationInstructions(plan: MigrationPlan): string[];
|
|
1862
|
+
|
|
2338
1863
|
/**
|
|
2339
|
-
*
|
|
1864
|
+
* Account Diagnostics Utility
|
|
2340
1865
|
*
|
|
2341
|
-
*
|
|
2342
|
-
*
|
|
2343
|
-
* @returns Promise<boolean> - True if mint has transfer fee extension
|
|
1866
|
+
* Comprehensive diagnostic tools for inspecting and debugging
|
|
1867
|
+
* account discriminator issues and data format problems.
|
|
2344
1868
|
*/
|
|
2345
|
-
|
|
1869
|
+
|
|
1870
|
+
interface DiagnosticReport {
|
|
1871
|
+
address: string;
|
|
1872
|
+
timestamp: string;
|
|
1873
|
+
accountExists: boolean;
|
|
1874
|
+
discriminatorValidation: ReturnType<typeof validateAccountDiscriminator>;
|
|
1875
|
+
inspection: AccountInspectionResult;
|
|
1876
|
+
migrationPlan: Awaited<ReturnType<typeof createMigrationPlan>>;
|
|
1877
|
+
migrationSimulation: Awaited<ReturnType<typeof simulateMigration>>;
|
|
1878
|
+
recommendations: string[];
|
|
1879
|
+
debugInfo: {
|
|
1880
|
+
expectedDiscriminator: number[];
|
|
1881
|
+
actualDiscriminator: number[] | null;
|
|
1882
|
+
dataPreview: number[];
|
|
1883
|
+
programId?: string;
|
|
1884
|
+
};
|
|
1885
|
+
}
|
|
1886
|
+
interface BatchDiagnosticReport {
|
|
1887
|
+
summary: {
|
|
1888
|
+
total: number;
|
|
1889
|
+
valid: number;
|
|
1890
|
+
invalid: number;
|
|
1891
|
+
needsMigration: number;
|
|
1892
|
+
notExists: number;
|
|
1893
|
+
};
|
|
1894
|
+
reports: DiagnosticReport[];
|
|
1895
|
+
globalRecommendations: string[];
|
|
1896
|
+
timestamp: string;
|
|
1897
|
+
}
|
|
2346
1898
|
/**
|
|
2347
|
-
*
|
|
2348
|
-
*
|
|
2349
|
-
* @param mint - The token mint address
|
|
2350
|
-
* @param rpcEndpoint - Optional RPC endpoint
|
|
2351
|
-
* @returns Promise<boolean> - True if mint has confidential transfer extension
|
|
1899
|
+
* Runs comprehensive diagnostics on a single account
|
|
2352
1900
|
*/
|
|
2353
|
-
declare function
|
|
1901
|
+
declare function runAccountDiagnostics(encodedAccount: EncodedAccount | MaybeEncodedAccount, address: string): Promise<DiagnosticReport>;
|
|
2354
1902
|
/**
|
|
2355
|
-
*
|
|
2356
|
-
*
|
|
2357
|
-
* @param mint - The token mint address
|
|
2358
|
-
* @param rpcEndpoint - Optional RPC endpoint
|
|
2359
|
-
* @returns Promise<boolean> - True if mint has interest-bearing extension
|
|
1903
|
+
* Runs diagnostics on multiple accounts
|
|
2360
1904
|
*/
|
|
2361
|
-
declare function
|
|
1905
|
+
declare function runBatchDiagnostics(accounts: {
|
|
1906
|
+
address: string;
|
|
1907
|
+
encodedAccount: EncodedAccount | MaybeEncodedAccount;
|
|
1908
|
+
}[]): Promise<BatchDiagnosticReport>;
|
|
2362
1909
|
/**
|
|
2363
|
-
*
|
|
2364
|
-
*
|
|
2365
|
-
* @param mint - The Token 2022 mint address
|
|
2366
|
-
* @returns Promise<TransferFeeConfig | null> - Transfer fee config or null if not configured
|
|
1910
|
+
* Fetches and diagnoses an account directly from the blockchain
|
|
2367
1911
|
*/
|
|
2368
|
-
declare function
|
|
1912
|
+
declare function diagnoseAccountFromChain(rpc: Parameters<typeof fetchEncodedAccount>[0], address: Address, options?: {
|
|
1913
|
+
logToConsole?: boolean;
|
|
1914
|
+
}): Promise<DiagnosticReport>;
|
|
2369
1915
|
/**
|
|
2370
|
-
*
|
|
2371
|
-
*
|
|
2372
|
-
* @param mint - The Token 2022 mint address
|
|
2373
|
-
* @returns Promise<ConfidentialTransferConfig | null> - Confidential transfer config or null
|
|
1916
|
+
* Fetches and diagnoses multiple accounts from the blockchain
|
|
2374
1917
|
*/
|
|
2375
|
-
declare function
|
|
1918
|
+
declare function diagnoseBatchFromChain(rpc: Parameters<typeof fetchEncodedAccount>[0], addresses: Address[], options?: {
|
|
1919
|
+
logToConsole?: boolean;
|
|
1920
|
+
maxConcurrent?: number;
|
|
1921
|
+
}): Promise<BatchDiagnosticReport>;
|
|
2376
1922
|
/**
|
|
2377
|
-
*
|
|
2378
|
-
*
|
|
2379
|
-
* @param mint - The Token 2022 mint address
|
|
2380
|
-
* @returns Promise<InterestBearingConfig | null> - Interest-bearing config or null
|
|
1923
|
+
* Exports a diagnostic report as JSON
|
|
2381
1924
|
*/
|
|
2382
|
-
declare function
|
|
1925
|
+
declare function exportDiagnosticReport(report: DiagnosticReport | BatchDiagnosticReport, filename?: string): string;
|
|
1926
|
+
|
|
1927
|
+
type accountDiagnostics_BatchDiagnosticReport = BatchDiagnosticReport;
|
|
1928
|
+
type accountDiagnostics_DiagnosticReport = DiagnosticReport;
|
|
1929
|
+
declare const accountDiagnostics_diagnoseAccountFromChain: typeof diagnoseAccountFromChain;
|
|
1930
|
+
declare const accountDiagnostics_diagnoseBatchFromChain: typeof diagnoseBatchFromChain;
|
|
1931
|
+
declare const accountDiagnostics_exportDiagnosticReport: typeof exportDiagnosticReport;
|
|
1932
|
+
declare const accountDiagnostics_runAccountDiagnostics: typeof runAccountDiagnostics;
|
|
1933
|
+
declare const accountDiagnostics_runBatchDiagnostics: typeof runBatchDiagnostics;
|
|
1934
|
+
declare namespace accountDiagnostics {
|
|
1935
|
+
export { type accountDiagnostics_BatchDiagnosticReport as BatchDiagnosticReport, type accountDiagnostics_DiagnosticReport as DiagnosticReport, accountDiagnostics_diagnoseAccountFromChain as diagnoseAccountFromChain, accountDiagnostics_diagnoseBatchFromChain as diagnoseBatchFromChain, accountDiagnostics_exportDiagnosticReport as exportDiagnosticReport, accountDiagnostics_runAccountDiagnostics as runAccountDiagnostics, accountDiagnostics_runBatchDiagnostics as runBatchDiagnostics };
|
|
1936
|
+
}
|
|
1937
|
+
|
|
2383
1938
|
/**
|
|
2384
|
-
*
|
|
2385
|
-
*
|
|
2386
|
-
*
|
|
2387
|
-
* @param owner - The wallet/owner address
|
|
2388
|
-
* @param mint - The token mint address
|
|
2389
|
-
* @returns Promise<{ splToken: Address, token2022: Address }> - Both ATA addresses
|
|
1939
|
+
* Utility functions for Program Derived Addresses (PDAs)
|
|
1940
|
+
* Based on generated patterns from Codama
|
|
2390
1941
|
*/
|
|
2391
|
-
declare function getAllAssociatedTokenAddresses(owner: Address$1, mint: Address$1): Promise<{
|
|
2392
|
-
splToken: Address$1;
|
|
2393
|
-
token2022: Address$1;
|
|
2394
|
-
}>;
|
|
2395
1942
|
/**
|
|
2396
|
-
*
|
|
2397
|
-
*
|
|
2398
|
-
*
|
|
2399
|
-
* @param owner - The expected owner
|
|
2400
|
-
* @param mint - The expected mint
|
|
2401
|
-
* @returns Promise<{ isValid: boolean, program?: Address }> - Validation result
|
|
1943
|
+
* Derive agent PDA
|
|
1944
|
+
* Pattern: ['agent', owner, agentId]
|
|
1945
|
+
* NOTE: Uses raw UTF-8 bytes to match smart contract's agent_id.as_bytes()
|
|
2402
1946
|
*/
|
|
2403
|
-
declare function
|
|
2404
|
-
isValid: boolean;
|
|
2405
|
-
program?: Address$1;
|
|
2406
|
-
}>;
|
|
1947
|
+
declare function deriveAgentPda(programId: Address$1, owner: Address$1, agentId: string): Promise<Address$1>;
|
|
2407
1948
|
/**
|
|
2408
|
-
*
|
|
2409
|
-
*
|
|
2410
|
-
* @param program - The token program enum
|
|
2411
|
-
* @returns Address - The program address
|
|
1949
|
+
* Derive service listing PDA
|
|
1950
|
+
* Pattern: ['service_listing', creator, listingId]
|
|
2412
1951
|
*/
|
|
2413
|
-
declare function
|
|
1952
|
+
declare function deriveServiceListingPda(programId: Address$1, creator: Address$1, listingId: string): Promise<Address$1>;
|
|
2414
1953
|
/**
|
|
2415
|
-
*
|
|
2416
|
-
*
|
|
2417
|
-
* @param address - The program address
|
|
2418
|
-
* @returns TokenProgram - The token program enum
|
|
1954
|
+
* Derive job posting PDA
|
|
1955
|
+
* Pattern: ['job_posting', employer, jobId]
|
|
2419
1956
|
*/
|
|
2420
|
-
declare function
|
|
1957
|
+
declare function deriveJobPostingPda(programId: Address$1, employer: Address$1, jobId: string): Promise<Address$1>;
|
|
2421
1958
|
/**
|
|
2422
|
-
*
|
|
2423
|
-
*
|
|
2424
|
-
* @param amount - Raw token amount (in base units)
|
|
2425
|
-
* @param decimals - Number of decimal places for the token
|
|
2426
|
-
* @returns string - Formatted amount
|
|
1959
|
+
* Derive job application PDA
|
|
1960
|
+
* Pattern: ['job_application', jobPosting, applicant]
|
|
2427
1961
|
*/
|
|
2428
|
-
declare function
|
|
1962
|
+
declare function deriveJobApplicationPda(programId: Address$1, jobPosting: Address$1, applicant: Address$1): Promise<Address$1>;
|
|
2429
1963
|
/**
|
|
2430
|
-
*
|
|
2431
|
-
*
|
|
2432
|
-
*
|
|
2433
|
-
* @param decimals - Number of decimal places for the token
|
|
2434
|
-
* @returns bigint - Raw token amount
|
|
1964
|
+
* Derive work order PDA (used for escrow functionality)
|
|
1965
|
+
* Pattern: ['work_order', client, orderId] (little-endian bytes)
|
|
1966
|
+
* NOTE: Smart contract expects orderId as little-endian bytes, not U64 encoded
|
|
2435
1967
|
*/
|
|
2436
|
-
declare function
|
|
2437
|
-
|
|
1968
|
+
declare function deriveWorkOrderPda(programId: Address$1, client: Address$1, orderId: bigint): Promise<Address$1>;
|
|
2438
1969
|
/**
|
|
2439
|
-
*
|
|
2440
|
-
*
|
|
2441
|
-
* Implements advanced Token 2022 features including:
|
|
2442
|
-
* - Transfer fees with withdrawal mechanisms
|
|
2443
|
-
* - Confidential transfers using ElGamal encryption
|
|
2444
|
-
* - Interest-bearing tokens with rate calculations
|
|
2445
|
-
* - Transfer hooks and metadata pointers
|
|
2446
|
-
* - Account state management and CPI guards
|
|
2447
|
-
*
|
|
2448
|
-
* Based on the SPL Token 2022 specification and Solana Web3.js v2.3.0
|
|
1970
|
+
* Derive work delivery PDA
|
|
1971
|
+
* Pattern: ['work_delivery', workOrder, provider]
|
|
2449
1972
|
*/
|
|
2450
|
-
|
|
1973
|
+
declare function deriveWorkDeliveryPda(programId: Address$1, workOrder: Address$1, provider: Address$1): Promise<Address$1>;
|
|
2451
1974
|
/**
|
|
2452
|
-
*
|
|
1975
|
+
* Derive payment PDA
|
|
1976
|
+
* Pattern: ['payment', workOrder, payer]
|
|
2453
1977
|
*/
|
|
2454
|
-
|
|
2455
|
-
/** Original transfer amount */
|
|
2456
|
-
transferAmount: bigint;
|
|
2457
|
-
/** Calculated fee amount */
|
|
2458
|
-
feeAmount: bigint;
|
|
2459
|
-
/** Amount after fee deduction */
|
|
2460
|
-
netAmount: bigint;
|
|
2461
|
-
/** Fee percentage (basis points) */
|
|
2462
|
-
feeBasisPoints: number;
|
|
2463
|
-
/** Whether fee was capped at maximum */
|
|
2464
|
-
wasFeeCapped: boolean;
|
|
2465
|
-
}
|
|
1978
|
+
declare function derivePaymentPda(programId: Address$1, workOrder: Address$1, payer: Address$1): Promise<Address$1>;
|
|
2466
1979
|
/**
|
|
2467
|
-
*
|
|
2468
|
-
*
|
|
2469
|
-
* @param transferAmount - Amount being transferred (in token base units)
|
|
2470
|
-
* @param feeConfig - Transfer fee configuration
|
|
2471
|
-
* @returns TransferFeeCalculation - Detailed fee calculation
|
|
1980
|
+
* Derive A2A session PDA
|
|
1981
|
+
* Pattern: ['a2a_session', creator]
|
|
2472
1982
|
*/
|
|
2473
|
-
declare function
|
|
1983
|
+
declare function deriveA2ASessionPda(programId: Address$1, creator: Address$1): Promise<Address$1>;
|
|
2474
1984
|
/**
|
|
2475
|
-
*
|
|
2476
|
-
*
|
|
2477
|
-
*
|
|
2478
|
-
* @param desiredNetAmount - The amount you want the recipient to receive
|
|
2479
|
-
* @param feeConfig - Transfer fee configuration
|
|
2480
|
-
* @returns TransferFeeCalculation - Required total amount and fee breakdown
|
|
1985
|
+
* Derive A2A message PDA
|
|
1986
|
+
* Pattern: ['a2a_message', session, session.created_at]
|
|
1987
|
+
* NOTE: Fixed to match smart contract expectation - uses session.created_at as little-endian bytes
|
|
2481
1988
|
*/
|
|
2482
|
-
declare function
|
|
1989
|
+
declare function deriveA2AMessagePda(programId: Address$1, session: Address$1, sessionCreatedAt: bigint): Promise<Address$1>;
|
|
2483
1990
|
/**
|
|
2484
|
-
*
|
|
2485
|
-
*
|
|
2486
|
-
*
|
|
2487
|
-
* @param feeConfig - Transfer fee configuration
|
|
2488
|
-
* @returns { totalFees: bigint, feeBreakdown: TransferFeeCalculation[] }
|
|
1991
|
+
* Derive user registry PDA
|
|
1992
|
+
* Pattern: ['user_registry', signer]
|
|
1993
|
+
* NOTE: Fixed to match smart contract expectations - includes signer address
|
|
2489
1994
|
*/
|
|
2490
|
-
declare function
|
|
2491
|
-
totalFees: bigint;
|
|
2492
|
-
feeBreakdown: TransferFeeCalculation[];
|
|
2493
|
-
};
|
|
1995
|
+
declare function deriveUserRegistryPda(programId: Address$1, signer: Address$1): Promise<Address$1>;
|
|
2494
1996
|
/**
|
|
2495
|
-
*
|
|
2496
|
-
*
|
|
2497
|
-
* complex zero-knowledge proof data structures
|
|
1997
|
+
* Derive service purchase PDA
|
|
1998
|
+
* Pattern: ['service_purchase', serviceListing, buyer]
|
|
2498
1999
|
*/
|
|
2499
|
-
|
|
2500
|
-
/** Encrypted transfer amount (ElGamal ciphertext) */
|
|
2501
|
-
encryptedAmount: Uint8Array;
|
|
2502
|
-
/** Range proof for the transfer amount */
|
|
2503
|
-
rangeProof: Uint8Array;
|
|
2504
|
-
/** Validity proof for the transfer */
|
|
2505
|
-
validityProof: Uint8Array;
|
|
2506
|
-
/** Auditor proof (if auditing is enabled) */
|
|
2507
|
-
auditorProof?: Uint8Array;
|
|
2508
|
-
}
|
|
2000
|
+
declare function deriveServicePurchasePda(programId: Address$1, serviceListing: Address$1, buyer: Address$1): Promise<Address$1>;
|
|
2509
2001
|
/**
|
|
2510
|
-
*
|
|
2002
|
+
* Derive agent verification PDA
|
|
2003
|
+
* Pattern: ['agent_verification', agent, verifier]
|
|
2511
2004
|
*/
|
|
2512
|
-
|
|
2513
|
-
/** Whether the account is approved for confidential transfers */
|
|
2514
|
-
approved: boolean;
|
|
2515
|
-
/** Encrypted balance (ElGamal ciphertext) */
|
|
2516
|
-
encryptedBalance: Uint8Array;
|
|
2517
|
-
/** Pending balance encryption from incoming transfers */
|
|
2518
|
-
pendingBalanceCredits: Uint8Array;
|
|
2519
|
-
/** Number of pending credits */
|
|
2520
|
-
pendingBalanceCreditsCounter: number;
|
|
2521
|
-
/** Expected pending balance decryption */
|
|
2522
|
-
expectedPendingBalanceCredits: bigint;
|
|
2523
|
-
/** Actual pending balance decryption */
|
|
2524
|
-
actualPendingBalanceCredits: bigint;
|
|
2525
|
-
}
|
|
2005
|
+
declare function deriveAgentVerificationPda(programId: Address$1, agent: Address$1, verifier: Address$1): Promise<Address$1>;
|
|
2526
2006
|
/**
|
|
2527
|
-
*
|
|
2528
|
-
*
|
|
2529
|
-
* Uses twisted ElGamal encryption to create confidential transfer proofs
|
|
2530
|
-
* compatible with Solana's ZK ElGamal Proof Program
|
|
2531
|
-
*
|
|
2532
|
-
* @param amount - Transfer amount (in token base units)
|
|
2533
|
-
* @param senderKeypair - Sender's ElGamal keypair
|
|
2534
|
-
* @param recipientPubkey - Recipient's ElGamal public key
|
|
2535
|
-
* @param auditorPubkey - Optional auditor public key
|
|
2536
|
-
* @returns Promise<ConfidentialTransferProof>
|
|
2007
|
+
* Generic PDA finder for custom use cases
|
|
2008
|
+
* Pattern: seeds array with automatic encoding
|
|
2537
2009
|
*/
|
|
2538
|
-
declare function
|
|
2010
|
+
declare function findProgramDerivedAddress(seeds: (string | Address$1 | Uint8Array)[], programId: Address$1): Promise<[Address$1, number]>;
|
|
2011
|
+
|
|
2539
2012
|
/**
|
|
2540
|
-
*
|
|
2541
|
-
*
|
|
2542
|
-
* Note: In practice, proof verification happens on-chain via the
|
|
2543
|
-
* ZK ElGamal Proof Program. This is a client-side validation helper.
|
|
2013
|
+
* Enhanced Client Error Utilities
|
|
2544
2014
|
*
|
|
2545
|
-
*
|
|
2546
|
-
*
|
|
2547
|
-
* @returns Promise<boolean> - True if proof is valid
|
|
2015
|
+
* Provides wrapper functions for SDK operations that automatically enhance
|
|
2016
|
+
* error messages with detailed instruction account information.
|
|
2548
2017
|
*/
|
|
2549
|
-
|
|
2550
|
-
senderPubkey: Uint8Array;
|
|
2551
|
-
recipientPubkey: Uint8Array;
|
|
2552
|
-
auditorPubkey?: Uint8Array;
|
|
2553
|
-
}): Promise<boolean>;
|
|
2018
|
+
|
|
2554
2019
|
/**
|
|
2555
|
-
*
|
|
2020
|
+
* Enhanced error class for SDK operations
|
|
2556
2021
|
*/
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
/** Time period for calculation (seconds) */
|
|
2563
|
-
timePeriodSeconds: bigint;
|
|
2564
|
-
/** Calculated interest amount */
|
|
2565
|
-
interestAmount: bigint;
|
|
2566
|
-
/** New total balance */
|
|
2567
|
-
newAmount: bigint;
|
|
2568
|
-
/** Effective annual rate */
|
|
2569
|
-
effectiveAnnualRate: number;
|
|
2022
|
+
declare class GhostSpeakSDKError extends Error {
|
|
2023
|
+
readonly originalError: Error;
|
|
2024
|
+
readonly operation: string;
|
|
2025
|
+
readonly instructionName?: string;
|
|
2026
|
+
constructor(operation: string, originalError: Error, instructionName?: string);
|
|
2570
2027
|
}
|
|
2571
2028
|
/**
|
|
2572
|
-
*
|
|
2573
|
-
*
|
|
2574
|
-
* @param principal - Current token balance
|
|
2575
|
-
* @param config - Interest-bearing configuration
|
|
2576
|
-
* @param currentTimestamp - Current timestamp (seconds)
|
|
2577
|
-
* @returns InterestCalculation - Detailed interest calculation
|
|
2029
|
+
* Type for account context
|
|
2578
2030
|
*/
|
|
2579
|
-
|
|
2031
|
+
type AccountContext = Address$1 | {
|
|
2032
|
+
address: Address$1;
|
|
2033
|
+
name?: string;
|
|
2034
|
+
};
|
|
2580
2035
|
/**
|
|
2581
|
-
*
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
*
|
|
2586
|
-
* @param years - Time period in years (can be fractional)
|
|
2587
|
-
* @returns InterestCalculation - Detailed compound interest calculation
|
|
2036
|
+
* Wrapper for async operations that enhances errors with instruction context
|
|
2037
|
+
*/
|
|
2038
|
+
declare function withEnhancedErrors<T>(operation: string, instructionName: string | undefined, fn: () => Promise<T>, debugAccounts?: AccountContext[]): Promise<T>;
|
|
2039
|
+
/**
|
|
2040
|
+
* Wrapper for synchronous operations that enhances errors with instruction context
|
|
2588
2041
|
*/
|
|
2589
|
-
declare function
|
|
2042
|
+
declare function withEnhancedErrorsSync<T>(operation: string, instructionName: string | undefined, fn: () => T, debugAccounts?: AccountContext[]): T;
|
|
2590
2043
|
/**
|
|
2591
|
-
*
|
|
2044
|
+
* Parse and enhance transaction errors with instruction context
|
|
2592
2045
|
*/
|
|
2593
|
-
|
|
2594
|
-
/** Program ID of the hook */
|
|
2595
|
-
programId: Address$1;
|
|
2596
|
-
/** Instruction data to pass to the hook */
|
|
2597
|
-
instructionData: Uint8Array;
|
|
2598
|
-
/** Additional accounts required by the hook */
|
|
2599
|
-
additionalAccounts: Address$1[];
|
|
2600
|
-
}
|
|
2046
|
+
declare function enhanceTransactionError(error: Error, instructionName?: string, accounts?: AccountContext[]): Error;
|
|
2601
2047
|
/**
|
|
2602
|
-
*
|
|
2048
|
+
* Helper to log detailed error information for debugging
|
|
2603
2049
|
*/
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2050
|
+
declare function logEnhancedError(error: Error, context?: {
|
|
2051
|
+
operation?: string;
|
|
2052
|
+
instructionName?: string;
|
|
2053
|
+
accounts?: AccountContext[];
|
|
2054
|
+
params?: Record<string, unknown>;
|
|
2055
|
+
}): void;
|
|
2056
|
+
/**
|
|
2057
|
+
* Error context for operations
|
|
2058
|
+
*/
|
|
2059
|
+
interface ErrorContext {
|
|
2060
|
+
operation: string;
|
|
2061
|
+
instructionName?: string;
|
|
2062
|
+
accounts?: AccountContext[];
|
|
2063
|
+
params?: Record<string, unknown>;
|
|
2617
2064
|
}
|
|
2618
2065
|
/**
|
|
2619
|
-
*
|
|
2620
|
-
*
|
|
2621
|
-
* @param instruction - The hook instruction to validate
|
|
2622
|
-
* @returns boolean - True if instruction format is valid
|
|
2066
|
+
* Create a detailed error context for operations
|
|
2623
2067
|
*/
|
|
2624
|
-
declare function
|
|
2068
|
+
declare function createErrorContext(operation: string, instructionName?: string, accounts?: AccountContext[], params?: Record<string, unknown>): ErrorContext;
|
|
2625
2069
|
/**
|
|
2626
|
-
*
|
|
2627
|
-
*
|
|
2628
|
-
* @param hookProgramId - Program ID of the transfer hook
|
|
2629
|
-
* @param context - Transfer context data
|
|
2630
|
-
* @returns TransferHookInstruction - Formatted instruction
|
|
2070
|
+
* Validate common preconditions and throw enhanced errors
|
|
2631
2071
|
*/
|
|
2632
|
-
declare function
|
|
2072
|
+
declare function validatePreconditions(checks: {
|
|
2073
|
+
condition: boolean;
|
|
2074
|
+
message: string;
|
|
2075
|
+
instructionName?: string;
|
|
2076
|
+
}[]): void;
|
|
2633
2077
|
/**
|
|
2634
|
-
*
|
|
2078
|
+
* Helper to extract instruction name from operation context
|
|
2635
2079
|
*/
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
name: string;
|
|
2639
|
-
/** Token symbol */
|
|
2640
|
-
symbol: string;
|
|
2641
|
-
/** Token description */
|
|
2642
|
-
description: string;
|
|
2643
|
-
/** Token image URI */
|
|
2644
|
-
image?: string;
|
|
2645
|
-
/** External URI for additional metadata */
|
|
2646
|
-
externalUri?: string;
|
|
2647
|
-
/** Additional attributes */
|
|
2648
|
-
attributes?: {
|
|
2649
|
-
trait_type: string;
|
|
2650
|
-
value: string;
|
|
2651
|
-
}[];
|
|
2652
|
-
}
|
|
2080
|
+
declare function extractInstructionName(operation: string): string | undefined;
|
|
2081
|
+
|
|
2653
2082
|
/**
|
|
2654
|
-
*
|
|
2083
|
+
* Proof data structure for transfer verification
|
|
2655
2084
|
*/
|
|
2656
|
-
interface
|
|
2657
|
-
/**
|
|
2658
|
-
|
|
2659
|
-
/**
|
|
2660
|
-
|
|
2085
|
+
interface TransferProofData {
|
|
2086
|
+
/** The encrypted transfer amount (ElGamal ciphertext) */
|
|
2087
|
+
encryptedTransferAmount: Uint8Array;
|
|
2088
|
+
/** Source account's new encrypted balance commitment */
|
|
2089
|
+
newSourceCommitment: Uint8Array;
|
|
2090
|
+
/** Equality proof for source balance */
|
|
2091
|
+
equalityProof: Uint8Array;
|
|
2092
|
+
/** Validity proof for the transfer */
|
|
2093
|
+
validityProof: Uint8Array;
|
|
2094
|
+
/** Range proof for the transfer amount and remaining balance */
|
|
2095
|
+
rangeProof: Uint8Array;
|
|
2661
2096
|
}
|
|
2097
|
+
|
|
2662
2098
|
/**
|
|
2663
|
-
*
|
|
2099
|
+
* Token Utilities for SPL Token and Token 2022 (Token Extensions)
|
|
2664
2100
|
*
|
|
2665
|
-
*
|
|
2666
|
-
*
|
|
2101
|
+
* Provides comprehensive token handling utilities including:
|
|
2102
|
+
* - Associated Token Account (ATA) derivation for both SPL Token and Token 2022
|
|
2103
|
+
* - Token 2022 specific features (transfer fees, confidential transfers, etc.)
|
|
2104
|
+
* - Token program detection and validation
|
|
2105
|
+
* - Account creation and management utilities
|
|
2106
|
+
*
|
|
2107
|
+
* Based on the latest SPL Token 2022 specification and @solana/kit v2.3.0
|
|
2667
2108
|
*/
|
|
2668
|
-
|
|
2109
|
+
|
|
2669
2110
|
/**
|
|
2670
|
-
*
|
|
2671
|
-
*
|
|
2672
|
-
* @param data - Serialized metadata bytes
|
|
2673
|
-
* @returns TokenMetadata - Parsed metadata object
|
|
2111
|
+
* Token program variants supported by GhostSpeak
|
|
2674
2112
|
*/
|
|
2675
|
-
declare
|
|
2113
|
+
declare enum TokenProgram {
|
|
2114
|
+
/** Original SPL Token Program */
|
|
2115
|
+
SPL_TOKEN = "spl-token",
|
|
2116
|
+
/** SPL Token 2022 (Token Extensions) Program */
|
|
2117
|
+
TOKEN_2022 = "token-2022"
|
|
2118
|
+
}
|
|
2676
2119
|
/**
|
|
2677
|
-
* Token
|
|
2120
|
+
* Associated Token Account information
|
|
2678
2121
|
*/
|
|
2679
|
-
|
|
2680
|
-
/**
|
|
2681
|
-
|
|
2682
|
-
/**
|
|
2683
|
-
|
|
2684
|
-
/**
|
|
2685
|
-
|
|
2122
|
+
interface AssociatedTokenAccount {
|
|
2123
|
+
/** The derived ATA address */
|
|
2124
|
+
address: Address$1;
|
|
2125
|
+
/** The wallet/owner address */
|
|
2126
|
+
owner: Address$1;
|
|
2127
|
+
/** The token mint address */
|
|
2128
|
+
mint: Address$1;
|
|
2129
|
+
/** The token program used (SPL Token or Token 2022) */
|
|
2130
|
+
tokenProgram: Address$1;
|
|
2131
|
+
/** Whether this is a Token 2022 ATA */
|
|
2132
|
+
isToken2022: boolean;
|
|
2686
2133
|
}
|
|
2687
2134
|
/**
|
|
2688
|
-
*
|
|
2135
|
+
* Token 2022 Extension Types
|
|
2136
|
+
* Based on the latest Token Extensions specification
|
|
2689
2137
|
*/
|
|
2690
|
-
|
|
2691
|
-
/**
|
|
2692
|
-
|
|
2693
|
-
/**
|
|
2694
|
-
|
|
2138
|
+
declare enum TokenExtension {
|
|
2139
|
+
/** Uninitialized account */
|
|
2140
|
+
UNINITIALIZED = 0,
|
|
2141
|
+
/** Transfer fee extension */
|
|
2142
|
+
TRANSFER_FEE_CONFIG = 1,
|
|
2143
|
+
/** Transfer fee amount */
|
|
2144
|
+
TRANSFER_FEE_AMOUNT = 2,
|
|
2145
|
+
/** Mint close authority */
|
|
2146
|
+
MINT_CLOSE_AUTHORITY = 3,
|
|
2147
|
+
/** Confidential transfer mint */
|
|
2148
|
+
CONFIDENTIAL_TRANSFER_MINT = 4,
|
|
2149
|
+
/** Confidential transfer account */
|
|
2150
|
+
CONFIDENTIAL_TRANSFER_ACCOUNT = 5,
|
|
2151
|
+
/** Default account state */
|
|
2152
|
+
DEFAULT_ACCOUNT_STATE = 6,
|
|
2153
|
+
/** Immutable owner */
|
|
2154
|
+
IMMUTABLE_OWNER = 7,
|
|
2155
|
+
/** Memo transfer */
|
|
2156
|
+
MEMO_TRANSFER = 8,
|
|
2157
|
+
/** Non-transferable */
|
|
2158
|
+
NON_TRANSFERABLE = 9,
|
|
2159
|
+
/** Interest bearing mint */
|
|
2160
|
+
INTEREST_BEARING_MINT = 10,
|
|
2161
|
+
/** CPI guard */
|
|
2162
|
+
CPI_GUARD = 11,
|
|
2163
|
+
/** Permanent delegate */
|
|
2164
|
+
PERMANENT_DELEGATE = 12,
|
|
2165
|
+
/** Non-transferable account */
|
|
2166
|
+
NON_TRANSFERABLE_ACCOUNT = 13,
|
|
2167
|
+
/** Transfer hook */
|
|
2168
|
+
TRANSFER_HOOK = 14,
|
|
2169
|
+
/** Transfer hook account */
|
|
2170
|
+
TRANSFER_HOOK_ACCOUNT = 15,
|
|
2171
|
+
/** Metadata pointer */
|
|
2172
|
+
METADATA_POINTER = 16,
|
|
2173
|
+
/** Token metadata */
|
|
2174
|
+
TOKEN_METADATA = 17,
|
|
2175
|
+
/** Group pointer */
|
|
2176
|
+
GROUP_POINTER = 18,
|
|
2177
|
+
/** Token group */
|
|
2178
|
+
TOKEN_GROUP = 19,
|
|
2179
|
+
/** Group member pointer */
|
|
2180
|
+
GROUP_MEMBER_POINTER = 20,
|
|
2181
|
+
/** Token group member */
|
|
2182
|
+
TOKEN_GROUP_MEMBER = 21
|
|
2695
2183
|
}
|
|
2696
2184
|
/**
|
|
2697
|
-
*
|
|
2185
|
+
* Transfer fee configuration for Token 2022
|
|
2698
2186
|
*/
|
|
2699
|
-
interface
|
|
2700
|
-
/**
|
|
2701
|
-
|
|
2187
|
+
interface TransferFeeConfig {
|
|
2188
|
+
/** Transfer fee basis points (0-10000, where 10000 = 100%) */
|
|
2189
|
+
transferFeeBasisPoints: number;
|
|
2190
|
+
/** Maximum transfer fee in token base units */
|
|
2191
|
+
maximumFee: bigint;
|
|
2192
|
+
/** Authority that can modify transfer fee config */
|
|
2193
|
+
transferFeeConfigAuthority: Address$1 | null;
|
|
2194
|
+
/** Authority that can withdraw collected fees */
|
|
2195
|
+
withdrawWithheldAuthority: Address$1 | null;
|
|
2196
|
+
/** Amount of fees currently withheld */
|
|
2197
|
+
withheldAmount: bigint;
|
|
2198
|
+
/** Older transfer fee configuration */
|
|
2199
|
+
olderTransferFee: {
|
|
2200
|
+
epoch: bigint;
|
|
2201
|
+
transferFeeBasisPoints: number;
|
|
2202
|
+
maximumFee: bigint;
|
|
2203
|
+
};
|
|
2204
|
+
/** Newer transfer fee configuration */
|
|
2205
|
+
newerTransferFee: {
|
|
2206
|
+
epoch: bigint;
|
|
2207
|
+
transferFeeBasisPoints: number;
|
|
2208
|
+
maximumFee: bigint;
|
|
2209
|
+
};
|
|
2702
2210
|
}
|
|
2703
2211
|
/**
|
|
2704
|
-
*
|
|
2212
|
+
* Confidential transfer configuration for Token 2022
|
|
2705
2213
|
*/
|
|
2706
|
-
interface
|
|
2707
|
-
/**
|
|
2708
|
-
|
|
2214
|
+
interface ConfidentialTransferConfig$1 {
|
|
2215
|
+
/** Authority that can configure confidential transfers */
|
|
2216
|
+
authority: Address$1 | null;
|
|
2217
|
+
/** Automatically approve new accounts for confidential transfers */
|
|
2218
|
+
autoApproveNewAccounts: boolean;
|
|
2219
|
+
/** Public key for auditing confidential transfers */
|
|
2220
|
+
auditorElgamalPubkey: Uint8Array | null;
|
|
2709
2221
|
}
|
|
2710
2222
|
/**
|
|
2711
|
-
*
|
|
2712
|
-
*
|
|
2713
|
-
* @param state - Current account state
|
|
2714
|
-
* @param isNonTransferable - Whether token is non-transferable
|
|
2715
|
-
* @param isFrozen - Whether account is frozen
|
|
2716
|
-
* @returns boolean - True if transfers are allowed
|
|
2223
|
+
* Interest-bearing token configuration for Token 2022
|
|
2717
2224
|
*/
|
|
2718
|
-
|
|
2225
|
+
interface InterestBearingConfig {
|
|
2226
|
+
/** Authority that can update the interest rate */
|
|
2227
|
+
rateAuthority: Address$1 | null;
|
|
2228
|
+
/** Current interest rate (basis points per year) */
|
|
2229
|
+
currentRate: number;
|
|
2230
|
+
/** Timestamp when interest bearing was initialized */
|
|
2231
|
+
initializationTimestamp: bigint;
|
|
2232
|
+
/** Timestamp of last rate update */
|
|
2233
|
+
lastUpdateTimestamp: bigint;
|
|
2234
|
+
/** Pre-computed interest rate */
|
|
2235
|
+
preUpdateAverageRate: number;
|
|
2236
|
+
}
|
|
2719
2237
|
/**
|
|
2720
|
-
*
|
|
2238
|
+
* Derive Associated Token Account address for any token program
|
|
2721
2239
|
*
|
|
2722
|
-
*
|
|
2723
|
-
*
|
|
2724
|
-
|
|
2725
|
-
declare function getRequiredExtensions(extensions: TokenExtension[]): TokenExtension[];
|
|
2726
|
-
/**
|
|
2727
|
-
* Convert basis points to percentage
|
|
2240
|
+
* This is the core ATA derivation function that works with both
|
|
2241
|
+
* SPL Token and Token 2022 programs. The derivation follows the
|
|
2242
|
+
* standard pattern: ['owner', 'token_program', 'mint']
|
|
2728
2243
|
*
|
|
2729
|
-
* @param
|
|
2730
|
-
* @
|
|
2244
|
+
* @param owner - The wallet/owner address
|
|
2245
|
+
* @param mint - The token mint address
|
|
2246
|
+
* @param tokenProgram - The token program address (SPL Token or Token 2022)
|
|
2247
|
+
* @returns Promise<Address> - The derived ATA address
|
|
2731
2248
|
*/
|
|
2732
|
-
declare function
|
|
2249
|
+
declare function deriveAssociatedTokenAddress(owner: Address$1, mint: Address$1, tokenProgram?: Address$1): Promise<Address$1>;
|
|
2733
2250
|
/**
|
|
2734
|
-
*
|
|
2251
|
+
* Derive Associated Token Account for SPL Token (legacy)
|
|
2735
2252
|
*
|
|
2736
|
-
* @param
|
|
2737
|
-
* @
|
|
2253
|
+
* @param owner - The wallet/owner address
|
|
2254
|
+
* @param mint - The token mint address
|
|
2255
|
+
* @returns Promise<Address> - The derived ATA address
|
|
2738
2256
|
*/
|
|
2739
|
-
declare function
|
|
2257
|
+
declare function deriveSplTokenAssociatedTokenAddress(owner: Address$1, mint: Address$1): Promise<Address$1>;
|
|
2740
2258
|
/**
|
|
2741
|
-
*
|
|
2259
|
+
* Derive Associated Token Account for Token 2022
|
|
2742
2260
|
*
|
|
2743
|
-
* @param
|
|
2744
|
-
* @
|
|
2261
|
+
* @param owner - The wallet/owner address
|
|
2262
|
+
* @param mint - The token mint address
|
|
2263
|
+
* @returns Promise<Address> - The derived ATA address
|
|
2745
2264
|
*/
|
|
2746
|
-
declare function
|
|
2265
|
+
declare function deriveToken2022AssociatedTokenAddress(owner: Address$1, mint: Address$1): Promise<Address$1>;
|
|
2747
2266
|
/**
|
|
2748
|
-
*
|
|
2267
|
+
* Get complete ATA information including program detection
|
|
2749
2268
|
*
|
|
2750
|
-
* @param
|
|
2751
|
-
* @param
|
|
2752
|
-
* @
|
|
2753
|
-
|
|
2754
|
-
declare function estimateComputeUnits(operation: 'transfer' | 'create_account' | 'mint' | 'burn', extensions?: TokenExtension[]): bigint;
|
|
2755
|
-
/**
|
|
2756
|
-
* Create transfer fee configuration with validation
|
|
2269
|
+
* @param owner - The wallet/owner address
|
|
2270
|
+
* @param mint - The token mint address
|
|
2271
|
+
* @param tokenProgram - Optional: specify token program, auto-detect if not provided
|
|
2272
|
+
* @returns Promise<AssociatedTokenAccount> - Complete ATA information
|
|
2757
2273
|
*/
|
|
2758
|
-
declare function
|
|
2759
|
-
transferFeeBasisPoints: number;
|
|
2760
|
-
maximumFee: bigint;
|
|
2761
|
-
transferFeeConfigAuthority: Address$1 | null;
|
|
2762
|
-
withdrawWithheldAuthority: Address$1 | null;
|
|
2763
|
-
}): TransferFeeConfig;
|
|
2274
|
+
declare function getAssociatedTokenAccount(owner: Address$1, mint: Address$1, tokenProgram?: Address$1): Promise<AssociatedTokenAccount>;
|
|
2764
2275
|
/**
|
|
2765
|
-
*
|
|
2276
|
+
* Detect which token program owns a given mint
|
|
2277
|
+
* Note: This requires RPC calls to fetch mint account data
|
|
2278
|
+
*
|
|
2279
|
+
* @param mint - The token mint address
|
|
2280
|
+
* @returns Promise<Address> - The token program address
|
|
2766
2281
|
*/
|
|
2767
|
-
declare function
|
|
2768
|
-
rateAuthority: Address$1 | null;
|
|
2769
|
-
currentRate: number;
|
|
2770
|
-
}): InterestBearingConfig;
|
|
2282
|
+
declare function detectTokenProgram(mint: Address$1, rpcEndpoint?: string): Promise<Address$1>;
|
|
2771
2283
|
/**
|
|
2772
|
-
*
|
|
2284
|
+
* Check if a mint is a Token 2022 mint
|
|
2285
|
+
*
|
|
2286
|
+
* @param mint - The token mint address
|
|
2287
|
+
* @returns Promise<boolean> - True if Token 2022, false if SPL Token
|
|
2773
2288
|
*/
|
|
2774
|
-
declare function
|
|
2775
|
-
|
|
2776
|
-
type token2022Extensions_ConfidentialAccountState = ConfidentialAccountState;
|
|
2777
|
-
type token2022Extensions_ConfidentialTransferProof = ConfidentialTransferProof;
|
|
2778
|
-
type token2022Extensions_CpiGuardConfig = CpiGuardConfig;
|
|
2779
|
-
type token2022Extensions_ImmutableOwnerConfig = ImmutableOwnerConfig;
|
|
2780
|
-
type token2022Extensions_InterestCalculation = InterestCalculation;
|
|
2781
|
-
type token2022Extensions_MetadataPointerConfig = MetadataPointerConfig;
|
|
2782
|
-
type token2022Extensions_NonTransferableConfig = NonTransferableConfig;
|
|
2783
|
-
type token2022Extensions_TokenAccountState = TokenAccountState;
|
|
2784
|
-
declare const token2022Extensions_TokenAccountState: typeof TokenAccountState;
|
|
2785
|
-
type token2022Extensions_TokenMetadata = TokenMetadata;
|
|
2786
|
-
type token2022Extensions_TransferFeeCalculation = TransferFeeCalculation;
|
|
2787
|
-
type token2022Extensions_TransferFeeConfig = TransferFeeConfig;
|
|
2788
|
-
type token2022Extensions_TransferHookContext = TransferHookContext;
|
|
2789
|
-
type token2022Extensions_TransferHookInstruction = TransferHookInstruction;
|
|
2790
|
-
declare const token2022Extensions_basisPointsToPercentage: typeof basisPointsToPercentage;
|
|
2791
|
-
declare const token2022Extensions_calculateCompoundInterest: typeof calculateCompoundInterest;
|
|
2792
|
-
declare const token2022Extensions_calculateInterest: typeof calculateInterest;
|
|
2793
|
-
declare const token2022Extensions_calculateRequiredAmountForNetTransfer: typeof calculateRequiredAmountForNetTransfer;
|
|
2794
|
-
declare const token2022Extensions_calculateTransferFee: typeof calculateTransferFee;
|
|
2795
|
-
declare const token2022Extensions_canTransfer: typeof canTransfer;
|
|
2796
|
-
declare const token2022Extensions_createInterestBearingConfig: typeof createInterestBearingConfig;
|
|
2797
|
-
declare const token2022Extensions_createTransferFeeConfig: typeof createTransferFeeConfig;
|
|
2798
|
-
declare const token2022Extensions_createTransferHookInstruction: typeof createTransferHookInstruction;
|
|
2799
|
-
declare const token2022Extensions_deserializeTokenMetadata: typeof deserializeTokenMetadata;
|
|
2800
|
-
declare const token2022Extensions_estimateAccumulatedFees: typeof estimateAccumulatedFees;
|
|
2801
|
-
declare const token2022Extensions_estimateComputeUnits: typeof estimateComputeUnits;
|
|
2802
|
-
declare const token2022Extensions_formatBasisPoints: typeof formatBasisPoints;
|
|
2803
|
-
declare const token2022Extensions_generateConfidentialTransferProof: typeof generateConfidentialTransferProof;
|
|
2804
|
-
declare const token2022Extensions_getRequiredExtensions: typeof getRequiredExtensions;
|
|
2805
|
-
declare const token2022Extensions_parseTokenExtension: typeof parseTokenExtension;
|
|
2806
|
-
declare const token2022Extensions_percentageToBasisPoints: typeof percentageToBasisPoints;
|
|
2807
|
-
declare const token2022Extensions_serializeTokenMetadata: typeof serializeTokenMetadata;
|
|
2808
|
-
declare const token2022Extensions_validateTransferHookInstruction: typeof validateTransferHookInstruction;
|
|
2809
|
-
declare const token2022Extensions_verifyConfidentialTransferProof: typeof verifyConfidentialTransferProof;
|
|
2810
|
-
declare namespace token2022Extensions {
|
|
2811
|
-
export { type token2022Extensions_ConfidentialAccountState as ConfidentialAccountState, type token2022Extensions_ConfidentialTransferProof as ConfidentialTransferProof, type token2022Extensions_CpiGuardConfig as CpiGuardConfig, type token2022Extensions_ImmutableOwnerConfig as ImmutableOwnerConfig, type token2022Extensions_InterestCalculation as InterestCalculation, type token2022Extensions_MetadataPointerConfig as MetadataPointerConfig, type token2022Extensions_NonTransferableConfig as NonTransferableConfig, token2022Extensions_TokenAccountState as TokenAccountState, type token2022Extensions_TokenMetadata as TokenMetadata, type token2022Extensions_TransferFeeCalculation as TransferFeeCalculation, type token2022Extensions_TransferFeeConfig as TransferFeeConfig, type token2022Extensions_TransferHookContext as TransferHookContext, type token2022Extensions_TransferHookInstruction as TransferHookInstruction, token2022Extensions_basisPointsToPercentage as basisPointsToPercentage, token2022Extensions_calculateCompoundInterest as calculateCompoundInterest, token2022Extensions_calculateInterest as calculateInterest, token2022Extensions_calculateRequiredAmountForNetTransfer as calculateRequiredAmountForNetTransfer, token2022Extensions_calculateTransferFee as calculateTransferFee, token2022Extensions_canTransfer as canTransfer, token2022Extensions_createInterestBearingConfig as createInterestBearingConfig, token2022Extensions_createTransferFeeConfig as createTransferFeeConfig, token2022Extensions_createTransferHookInstruction as createTransferHookInstruction, token2022Extensions_deserializeTokenMetadata as deserializeTokenMetadata, token2022Extensions_estimateAccumulatedFees as estimateAccumulatedFees, token2022Extensions_estimateComputeUnits as estimateComputeUnits, token2022Extensions_formatBasisPoints as formatBasisPoints, token2022Extensions_generateConfidentialTransferProof as generateConfidentialTransferProof, token2022Extensions_getRequiredExtensions as getRequiredExtensions, token2022Extensions_parseTokenExtension as parseTokenExtension, token2022Extensions_percentageToBasisPoints as percentageToBasisPoints, token2022Extensions_serializeTokenMetadata as serializeTokenMetadata, token2022Extensions_validateTransferHookInstruction as validateTransferHookInstruction, token2022Extensions_verifyConfidentialTransferProof as verifyConfidentialTransferProof };
|
|
2812
|
-
}
|
|
2813
|
-
|
|
2289
|
+
declare function isToken2022Mint(mint: Address$1): Promise<boolean>;
|
|
2814
2290
|
/**
|
|
2815
|
-
*
|
|
2291
|
+
* Get the appropriate token program for a given mint
|
|
2816
2292
|
*
|
|
2817
|
-
*
|
|
2818
|
-
*
|
|
2293
|
+
* @param mint - The token mint address
|
|
2294
|
+
* @returns Promise<TokenProgram> - The token program enum
|
|
2819
2295
|
*/
|
|
2820
|
-
|
|
2821
|
-
interface DiscriminatorValidationResult {
|
|
2822
|
-
isValid: boolean;
|
|
2823
|
-
expectedLength: number;
|
|
2824
|
-
actualLength: number;
|
|
2825
|
-
canDecode: boolean;
|
|
2826
|
-
needsMigration: boolean;
|
|
2827
|
-
errorMessage?: string;
|
|
2828
|
-
}
|
|
2829
|
-
interface AccountInspectionResult {
|
|
2830
|
-
address: string;
|
|
2831
|
-
dataLength: number;
|
|
2832
|
-
discriminator: Uint8Array | null;
|
|
2833
|
-
discriminatorLength: number;
|
|
2834
|
-
isAgentAccount: boolean;
|
|
2835
|
-
needsMigration: boolean;
|
|
2836
|
-
rawData: Uint8Array;
|
|
2837
|
-
}
|
|
2296
|
+
declare function getTokenProgramType(mint: Address$1): Promise<TokenProgram>;
|
|
2838
2297
|
/**
|
|
2839
|
-
*
|
|
2298
|
+
* Check if a mint has the transfer fee extension
|
|
2299
|
+
*
|
|
2300
|
+
* @param mint - The token mint address
|
|
2301
|
+
* @param rpcEndpoint - Optional RPC endpoint
|
|
2302
|
+
* @returns Promise<boolean> - True if mint has transfer fee extension
|
|
2840
2303
|
*/
|
|
2841
|
-
declare function
|
|
2304
|
+
declare function hasTransferFeeExtension(mint: Address$1, rpcEndpoint?: string): Promise<boolean>;
|
|
2842
2305
|
/**
|
|
2843
|
-
*
|
|
2306
|
+
* Check if a mint has the confidential transfer extension
|
|
2307
|
+
*
|
|
2308
|
+
* @param mint - The token mint address
|
|
2309
|
+
* @param rpcEndpoint - Optional RPC endpoint
|
|
2310
|
+
* @returns Promise<boolean> - True if mint has confidential transfer extension
|
|
2844
2311
|
*/
|
|
2845
|
-
declare function
|
|
2312
|
+
declare function hasConfidentialTransferExtension(mint: Address$1, rpcEndpoint?: string): Promise<boolean>;
|
|
2846
2313
|
/**
|
|
2847
|
-
*
|
|
2848
|
-
*
|
|
2314
|
+
* Check if a mint has the interest-bearing extension
|
|
2315
|
+
*
|
|
2316
|
+
* @param mint - The token mint address
|
|
2317
|
+
* @param rpcEndpoint - Optional RPC endpoint
|
|
2318
|
+
* @returns Promise<boolean> - True if mint has interest-bearing extension
|
|
2849
2319
|
*/
|
|
2850
|
-
declare function
|
|
2851
|
-
address: Address$1;
|
|
2852
|
-
data: Uint8Array;
|
|
2853
|
-
}): Promise<{
|
|
2854
|
-
exists: boolean;
|
|
2855
|
-
data?: unknown;
|
|
2856
|
-
} | null>;
|
|
2320
|
+
declare function hasInterestBearingExtension(mint: Address$1, rpcEndpoint?: string): Promise<boolean>;
|
|
2857
2321
|
/**
|
|
2858
|
-
*
|
|
2322
|
+
* Get transfer fee configuration for a Token 2022 mint
|
|
2323
|
+
*
|
|
2324
|
+
* @param mint - The Token 2022 mint address
|
|
2325
|
+
* @returns Promise<TransferFeeConfig | null> - Transfer fee config or null if not configured
|
|
2859
2326
|
*/
|
|
2860
|
-
declare function
|
|
2861
|
-
|
|
2327
|
+
declare function getTransferFeeConfig(mint: Address$1, rpcEndpoint?: string): Promise<TransferFeeConfig | null>;
|
|
2862
2328
|
/**
|
|
2863
|
-
*
|
|
2329
|
+
* Get confidential transfer configuration for a Token 2022 mint
|
|
2864
2330
|
*
|
|
2865
|
-
*
|
|
2866
|
-
*
|
|
2331
|
+
* @param mint - The Token 2022 mint address
|
|
2332
|
+
* @returns Promise<ConfidentialTransferConfig | null> - Confidential transfer config or null
|
|
2867
2333
|
*/
|
|
2868
|
-
|
|
2869
|
-
interface MigrationPlan {
|
|
2870
|
-
address: string;
|
|
2871
|
-
currentState: 'valid' | 'needs_migration' | 'invalid' | 'not_exists';
|
|
2872
|
-
migrationType: 'none' | 'recreate' | 'data_conversion' | 'unsupported';
|
|
2873
|
-
issues: string[];
|
|
2874
|
-
recommendations: string[];
|
|
2875
|
-
canAutoMigrate: boolean;
|
|
2876
|
-
}
|
|
2877
|
-
interface MigrationResult {
|
|
2878
|
-
success: boolean;
|
|
2879
|
-
address: string;
|
|
2880
|
-
action: 'skipped' | 'migrated' | 'failed';
|
|
2881
|
-
error?: string;
|
|
2882
|
-
newAccountData?: Uint8Array;
|
|
2883
|
-
}
|
|
2884
|
-
interface LegacyAgentData {
|
|
2885
|
-
discriminator: Uint8Array;
|
|
2886
|
-
owner?: string;
|
|
2887
|
-
name?: string;
|
|
2888
|
-
}
|
|
2334
|
+
declare function getConfidentialTransferConfig(mint: Address$1, rpcEndpoint?: string): Promise<ConfidentialTransferConfig$1 | null>;
|
|
2889
2335
|
/**
|
|
2890
|
-
*
|
|
2336
|
+
* Get interest-bearing configuration for a Token 2022 mint
|
|
2337
|
+
*
|
|
2338
|
+
* @param mint - The Token 2022 mint address
|
|
2339
|
+
* @returns Promise<InterestBearingConfig | null> - Interest-bearing config or null
|
|
2891
2340
|
*/
|
|
2892
|
-
declare function
|
|
2341
|
+
declare function getInterestBearingConfig(mint: Address$1, rpcEndpoint?: string): Promise<InterestBearingConfig | null>;
|
|
2893
2342
|
/**
|
|
2894
|
-
*
|
|
2343
|
+
* Get all possible ATA addresses for a wallet/mint pair
|
|
2344
|
+
* Returns both SPL Token and Token 2022 ATAs
|
|
2345
|
+
*
|
|
2346
|
+
* @param owner - The wallet/owner address
|
|
2347
|
+
* @param mint - The token mint address
|
|
2348
|
+
* @returns Promise<{ splToken: Address, token2022: Address }> - Both ATA addresses
|
|
2895
2349
|
*/
|
|
2896
|
-
declare function
|
|
2350
|
+
declare function getAllAssociatedTokenAddresses(owner: Address$1, mint: Address$1): Promise<{
|
|
2351
|
+
splToken: Address$1;
|
|
2352
|
+
token2022: Address$1;
|
|
2353
|
+
}>;
|
|
2897
2354
|
/**
|
|
2898
|
-
*
|
|
2355
|
+
* Validate if an address could be a valid ATA
|
|
2356
|
+
*
|
|
2357
|
+
* @param address - The address to validate
|
|
2358
|
+
* @param owner - The expected owner
|
|
2359
|
+
* @param mint - The expected mint
|
|
2360
|
+
* @returns Promise<{ isValid: boolean, program?: Address }> - Validation result
|
|
2899
2361
|
*/
|
|
2900
|
-
declare function
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
}[]): Promise<{
|
|
2904
|
-
summary: {
|
|
2905
|
-
total: number;
|
|
2906
|
-
valid: number;
|
|
2907
|
-
needsMigration: number;
|
|
2908
|
-
invalid: number;
|
|
2909
|
-
canAutoMigrate: number;
|
|
2910
|
-
};
|
|
2911
|
-
plans: MigrationPlan[];
|
|
2912
|
-
recommendations: string[];
|
|
2362
|
+
declare function validateAssociatedTokenAddress(address: Address$1, owner: Address$1, mint: Address$1): Promise<{
|
|
2363
|
+
isValid: boolean;
|
|
2364
|
+
program?: Address$1;
|
|
2913
2365
|
}>;
|
|
2914
2366
|
/**
|
|
2915
|
-
*
|
|
2367
|
+
* Convert TokenProgram enum to program address
|
|
2368
|
+
*
|
|
2369
|
+
* @param program - The token program enum
|
|
2370
|
+
* @returns Address - The program address
|
|
2371
|
+
*/
|
|
2372
|
+
declare function getTokenProgramAddress(program: TokenProgram): Address$1;
|
|
2373
|
+
/**
|
|
2374
|
+
* Convert program address to TokenProgram enum
|
|
2375
|
+
*
|
|
2376
|
+
* @param address - The program address
|
|
2377
|
+
* @returns TokenProgram - The token program enum
|
|
2916
2378
|
*/
|
|
2917
|
-
declare function
|
|
2918
|
-
plan: MigrationPlan;
|
|
2919
|
-
simulation: {
|
|
2920
|
-
wouldSucceed: boolean;
|
|
2921
|
-
estimatedSteps: string[];
|
|
2922
|
-
warnings: string[];
|
|
2923
|
-
requiredActions: string[];
|
|
2924
|
-
};
|
|
2925
|
-
}>;
|
|
2379
|
+
declare function getTokenProgramFromAddress(address: Address$1): TokenProgram;
|
|
2926
2380
|
/**
|
|
2927
|
-
*
|
|
2381
|
+
* Format token amount with proper decimals
|
|
2382
|
+
*
|
|
2383
|
+
* @param amount - Raw token amount (in base units)
|
|
2384
|
+
* @param decimals - Number of decimal places for the token
|
|
2385
|
+
* @returns string - Formatted amount
|
|
2928
2386
|
*/
|
|
2929
|
-
declare function
|
|
2387
|
+
declare function formatTokenAmount(amount: bigint, decimals: number): string;
|
|
2388
|
+
/**
|
|
2389
|
+
* Parse formatted token amount to raw base units
|
|
2390
|
+
*
|
|
2391
|
+
* @param formatted - Formatted token amount string
|
|
2392
|
+
* @param decimals - Number of decimal places for the token
|
|
2393
|
+
* @returns bigint - Raw token amount
|
|
2394
|
+
*/
|
|
2395
|
+
declare function parseTokenAmount(formatted: string, decimals: number): bigint;
|
|
2930
2396
|
|
|
2931
2397
|
/**
|
|
2932
|
-
*
|
|
2398
|
+
* Complete ElGamal Encryption Module with Full ZK Proof Implementation
|
|
2933
2399
|
*
|
|
2934
|
-
*
|
|
2935
|
-
*
|
|
2400
|
+
* This module provides production-ready ElGamal encryption on Curve25519 with
|
|
2401
|
+
* complete zero-knowledge proof generation for Solana's confidential transfers.
|
|
2402
|
+
*
|
|
2403
|
+
* Features:
|
|
2404
|
+
* - ElGamal encryption/decryption on ed25519
|
|
2405
|
+
* - Bulletproof range proofs for amounts (0 to 2^64)
|
|
2406
|
+
* - Validity proofs for well-formed ciphertexts
|
|
2407
|
+
* - Equality proofs for value conservation
|
|
2408
|
+
* - Transfer proofs combining all necessary proofs
|
|
2409
|
+
* - Full integration with Solana's ZK ElGamal Proof Program
|
|
2936
2410
|
*/
|
|
2937
2411
|
|
|
2938
|
-
interface
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
accountExists: boolean;
|
|
2942
|
-
discriminatorValidation: ReturnType<typeof validateAccountDiscriminator>;
|
|
2943
|
-
inspection: AccountInspectionResult;
|
|
2944
|
-
migrationPlan: Awaited<ReturnType<typeof createMigrationPlan>>;
|
|
2945
|
-
migrationSimulation: Awaited<ReturnType<typeof simulateMigration>>;
|
|
2946
|
-
recommendations: string[];
|
|
2947
|
-
debugInfo: {
|
|
2948
|
-
expectedDiscriminator: number[];
|
|
2949
|
-
actualDiscriminator: number[] | null;
|
|
2950
|
-
dataPreview: number[];
|
|
2951
|
-
programId?: string;
|
|
2952
|
-
};
|
|
2412
|
+
interface ElGamalKeypair$1 {
|
|
2413
|
+
publicKey: Uint8Array;
|
|
2414
|
+
secretKey: Uint8Array;
|
|
2953
2415
|
}
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2416
|
+
|
|
2417
|
+
/**
|
|
2418
|
+
* Token 2022 Extensions Implementation
|
|
2419
|
+
*
|
|
2420
|
+
* Implements advanced Token 2022 features including:
|
|
2421
|
+
* - Transfer fees with withdrawal mechanisms
|
|
2422
|
+
* - Confidential transfers using ElGamal encryption
|
|
2423
|
+
* - Interest-bearing tokens with rate calculations
|
|
2424
|
+
* - Transfer hooks and metadata pointers
|
|
2425
|
+
* - Account state management and CPI guards
|
|
2426
|
+
*
|
|
2427
|
+
* Based on the SPL Token 2022 specification and Solana Web3.js v2.3.0
|
|
2428
|
+
*/
|
|
2429
|
+
|
|
2430
|
+
/**
|
|
2431
|
+
* Transfer fee calculation result
|
|
2432
|
+
*/
|
|
2433
|
+
interface TransferFeeCalculation {
|
|
2434
|
+
/** Original transfer amount */
|
|
2435
|
+
transferAmount: bigint;
|
|
2436
|
+
/** Calculated fee amount */
|
|
2437
|
+
feeAmount: bigint;
|
|
2438
|
+
/** Amount after fee deduction */
|
|
2439
|
+
netAmount: bigint;
|
|
2440
|
+
/** Fee percentage (basis points) */
|
|
2441
|
+
feeBasisPoints: number;
|
|
2442
|
+
/** Whether fee was capped at maximum */
|
|
2443
|
+
wasFeeCapped: boolean;
|
|
2965
2444
|
}
|
|
2966
2445
|
/**
|
|
2967
|
-
*
|
|
2446
|
+
* Calculate transfer fee for a Token 2022 transfer
|
|
2447
|
+
*
|
|
2448
|
+
* @param transferAmount - Amount being transferred (in token base units)
|
|
2449
|
+
* @param feeConfig - Transfer fee configuration
|
|
2450
|
+
* @returns TransferFeeCalculation - Detailed fee calculation
|
|
2968
2451
|
*/
|
|
2969
|
-
declare function
|
|
2452
|
+
declare function calculateTransferFee(transferAmount: bigint, feeConfig: TransferFeeConfig): TransferFeeCalculation;
|
|
2970
2453
|
/**
|
|
2971
|
-
*
|
|
2454
|
+
* Calculate the total amount needed for a desired net transfer
|
|
2455
|
+
* (reverse calculation when you want to send a specific net amount)
|
|
2456
|
+
*
|
|
2457
|
+
* @param desiredNetAmount - The amount you want the recipient to receive
|
|
2458
|
+
* @param feeConfig - Transfer fee configuration
|
|
2459
|
+
* @returns TransferFeeCalculation - Required total amount and fee breakdown
|
|
2972
2460
|
*/
|
|
2973
|
-
declare function
|
|
2974
|
-
address: string;
|
|
2975
|
-
encodedAccount: EncodedAccount | MaybeEncodedAccount;
|
|
2976
|
-
}[]): Promise<BatchDiagnosticReport>;
|
|
2461
|
+
declare function calculateRequiredAmountForNetTransfer(desiredNetAmount: bigint, feeConfig: TransferFeeConfig): TransferFeeCalculation;
|
|
2977
2462
|
/**
|
|
2978
|
-
*
|
|
2463
|
+
* Estimate accumulated fees for multiple transfers
|
|
2464
|
+
*
|
|
2465
|
+
* @param transfers - Array of transfer amounts
|
|
2466
|
+
* @param feeConfig - Transfer fee configuration
|
|
2467
|
+
* @returns { totalFees: bigint, feeBreakdown: TransferFeeCalculation[] }
|
|
2979
2468
|
*/
|
|
2980
|
-
declare function
|
|
2981
|
-
|
|
2982
|
-
|
|
2469
|
+
declare function estimateAccumulatedFees(transfers: bigint[], feeConfig: TransferFeeConfig): {
|
|
2470
|
+
totalFees: bigint;
|
|
2471
|
+
feeBreakdown: TransferFeeCalculation[];
|
|
2472
|
+
};
|
|
2983
2473
|
/**
|
|
2984
|
-
*
|
|
2474
|
+
* Confidential transfer proof data
|
|
2475
|
+
* Note: This is a simplified structure - actual implementation would include
|
|
2476
|
+
* complex zero-knowledge proof data structures
|
|
2985
2477
|
*/
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2478
|
+
interface ConfidentialTransferProof {
|
|
2479
|
+
/** Encrypted transfer amount (ElGamal ciphertext) */
|
|
2480
|
+
encryptedAmount: Uint8Array;
|
|
2481
|
+
/** Range proof for the transfer amount */
|
|
2482
|
+
rangeProof: Uint8Array;
|
|
2483
|
+
/** Validity proof for the transfer */
|
|
2484
|
+
validityProof: Uint8Array;
|
|
2485
|
+
/** Auditor proof (if auditing is enabled) */
|
|
2486
|
+
auditorProof?: Uint8Array;
|
|
2487
|
+
}
|
|
2990
2488
|
/**
|
|
2991
|
-
*
|
|
2489
|
+
* Confidential account state
|
|
2992
2490
|
*/
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
2491
|
+
interface ConfidentialAccountState {
|
|
2492
|
+
/** Whether the account is approved for confidential transfers */
|
|
2493
|
+
approved: boolean;
|
|
2494
|
+
/** Encrypted balance (ElGamal ciphertext) */
|
|
2495
|
+
encryptedBalance: Uint8Array;
|
|
2496
|
+
/** Pending balance encryption from incoming transfers */
|
|
2497
|
+
pendingBalanceCredits: Uint8Array;
|
|
2498
|
+
/** Number of pending credits */
|
|
2499
|
+
pendingBalanceCreditsCounter: number;
|
|
2500
|
+
/** Expected pending balance decryption */
|
|
2501
|
+
expectedPendingBalanceCredits: bigint;
|
|
2502
|
+
/** Actual pending balance decryption */
|
|
2503
|
+
actualPendingBalanceCredits: bigint;
|
|
3004
2504
|
}
|
|
3005
|
-
|
|
3006
2505
|
/**
|
|
3007
|
-
*
|
|
3008
|
-
*
|
|
2506
|
+
* Generate confidential transfer proof
|
|
2507
|
+
*
|
|
2508
|
+
* Uses twisted ElGamal encryption to create confidential transfer proofs
|
|
2509
|
+
* compatible with Solana's ZK ElGamal Proof Program
|
|
2510
|
+
*
|
|
2511
|
+
* @param amount - Transfer amount (in token base units)
|
|
2512
|
+
* @param senderKeypair - Sender's ElGamal keypair
|
|
2513
|
+
* @param recipientPubkey - Recipient's ElGamal public key
|
|
2514
|
+
* @param auditorPubkey - Optional auditor public key
|
|
2515
|
+
* @returns Promise<ConfidentialTransferProof>
|
|
3009
2516
|
*/
|
|
2517
|
+
declare function generateConfidentialTransferProof(amount: bigint, senderKeypair: ElGamalKeypair$1, recipientPubkey: Uint8Array, auditorPubkey?: Uint8Array): Promise<ConfidentialTransferProof>;
|
|
3010
2518
|
/**
|
|
3011
|
-
*
|
|
3012
|
-
*
|
|
3013
|
-
*
|
|
2519
|
+
* Verify confidential transfer proof
|
|
2520
|
+
*
|
|
2521
|
+
* Note: In practice, proof verification happens on-chain via the
|
|
2522
|
+
* ZK ElGamal Proof Program. This is a client-side validation helper.
|
|
2523
|
+
*
|
|
2524
|
+
* @param proof - The proof to verify
|
|
2525
|
+
* @param publicInputs - Public inputs for verification
|
|
2526
|
+
* @returns Promise<boolean> - True if proof is valid
|
|
3014
2527
|
*/
|
|
3015
|
-
declare function
|
|
2528
|
+
declare function verifyConfidentialTransferProof(proof: ConfidentialTransferProof, publicInputs: {
|
|
2529
|
+
senderPubkey: Uint8Array;
|
|
2530
|
+
recipientPubkey: Uint8Array;
|
|
2531
|
+
auditorPubkey?: Uint8Array;
|
|
2532
|
+
}): Promise<boolean>;
|
|
3016
2533
|
/**
|
|
3017
|
-
*
|
|
3018
|
-
* Pattern: ['service_listing', creator, listingId]
|
|
2534
|
+
* Interest calculation result
|
|
3019
2535
|
*/
|
|
3020
|
-
|
|
2536
|
+
interface InterestCalculation {
|
|
2537
|
+
/** Principal amount */
|
|
2538
|
+
principal: bigint;
|
|
2539
|
+
/** Interest rate (basis points per year) */
|
|
2540
|
+
annualRateBasisPoints: number;
|
|
2541
|
+
/** Time period for calculation (seconds) */
|
|
2542
|
+
timePeriodSeconds: bigint;
|
|
2543
|
+
/** Calculated interest amount */
|
|
2544
|
+
interestAmount: bigint;
|
|
2545
|
+
/** New total balance */
|
|
2546
|
+
newAmount: bigint;
|
|
2547
|
+
/** Effective annual rate */
|
|
2548
|
+
effectiveAnnualRate: number;
|
|
2549
|
+
}
|
|
3021
2550
|
/**
|
|
3022
|
-
*
|
|
3023
|
-
*
|
|
2551
|
+
* Calculate interest for an interest-bearing token
|
|
2552
|
+
*
|
|
2553
|
+
* @param principal - Current token balance
|
|
2554
|
+
* @param config - Interest-bearing configuration
|
|
2555
|
+
* @param currentTimestamp - Current timestamp (seconds)
|
|
2556
|
+
* @returns InterestCalculation - Detailed interest calculation
|
|
3024
2557
|
*/
|
|
3025
|
-
declare function
|
|
2558
|
+
declare function calculateInterest(principal: bigint, config: InterestBearingConfig, currentTimestamp: bigint): InterestCalculation;
|
|
3026
2559
|
/**
|
|
3027
|
-
*
|
|
3028
|
-
*
|
|
2560
|
+
* Calculate compound interest with custom compounding periods
|
|
2561
|
+
*
|
|
2562
|
+
* @param principal - Initial amount
|
|
2563
|
+
* @param annualRateBasisPoints - Annual interest rate (basis points)
|
|
2564
|
+
* @param compoundingPeriodsPerYear - Number of compounding periods per year (e.g., 12 for monthly)
|
|
2565
|
+
* @param years - Time period in years (can be fractional)
|
|
2566
|
+
* @returns InterestCalculation - Detailed compound interest calculation
|
|
3029
2567
|
*/
|
|
3030
|
-
declare function
|
|
2568
|
+
declare function calculateCompoundInterest(principal: bigint, annualRateBasisPoints: number, compoundingPeriodsPerYear: number, years: number): InterestCalculation;
|
|
2569
|
+
/**
|
|
2570
|
+
* Transfer hook instruction data
|
|
2571
|
+
*/
|
|
2572
|
+
interface TransferHookInstruction {
|
|
2573
|
+
/** Program ID of the hook */
|
|
2574
|
+
programId: Address$1;
|
|
2575
|
+
/** Instruction data to pass to the hook */
|
|
2576
|
+
instructionData: Uint8Array;
|
|
2577
|
+
/** Additional accounts required by the hook */
|
|
2578
|
+
additionalAccounts: Address$1[];
|
|
2579
|
+
}
|
|
3031
2580
|
/**
|
|
3032
|
-
*
|
|
3033
|
-
* Pattern: ['work_order', client, orderId] (little-endian bytes)
|
|
3034
|
-
* NOTE: Smart contract expects orderId as little-endian bytes, not U64 encoded
|
|
2581
|
+
* Transfer hook context passed to hook programs
|
|
3035
2582
|
*/
|
|
3036
|
-
|
|
2583
|
+
interface TransferHookContext {
|
|
2584
|
+
/** Source account */
|
|
2585
|
+
source: Address$1;
|
|
2586
|
+
/** Destination account */
|
|
2587
|
+
destination: Address$1;
|
|
2588
|
+
/** Authority performing the transfer */
|
|
2589
|
+
authority: Address$1;
|
|
2590
|
+
/** Transfer amount */
|
|
2591
|
+
amount: bigint;
|
|
2592
|
+
/** Token mint */
|
|
2593
|
+
mint: Address$1;
|
|
2594
|
+
/** Additional context data */
|
|
2595
|
+
contextData: Uint8Array;
|
|
2596
|
+
}
|
|
3037
2597
|
/**
|
|
3038
|
-
*
|
|
3039
|
-
*
|
|
2598
|
+
* Validate transfer hook instruction format
|
|
2599
|
+
*
|
|
2600
|
+
* @param instruction - The hook instruction to validate
|
|
2601
|
+
* @returns boolean - True if instruction format is valid
|
|
3040
2602
|
*/
|
|
3041
|
-
declare function
|
|
2603
|
+
declare function validateTransferHookInstruction(instruction: TransferHookInstruction): boolean;
|
|
3042
2604
|
/**
|
|
3043
|
-
*
|
|
3044
|
-
*
|
|
2605
|
+
* Create transfer hook instruction data
|
|
2606
|
+
*
|
|
2607
|
+
* @param hookProgramId - Program ID of the transfer hook
|
|
2608
|
+
* @param context - Transfer context data
|
|
2609
|
+
* @returns TransferHookInstruction - Formatted instruction
|
|
3045
2610
|
*/
|
|
3046
|
-
declare function
|
|
2611
|
+
declare function createTransferHookInstruction(hookProgramId: Address$1, context: TransferHookContext): TransferHookInstruction;
|
|
3047
2612
|
/**
|
|
3048
|
-
*
|
|
3049
|
-
* Pattern: ['a2a_session', creator]
|
|
2613
|
+
* Token metadata structure (simplified)
|
|
3050
2614
|
*/
|
|
3051
|
-
|
|
2615
|
+
interface TokenMetadata {
|
|
2616
|
+
/** Token name */
|
|
2617
|
+
name: string;
|
|
2618
|
+
/** Token symbol */
|
|
2619
|
+
symbol: string;
|
|
2620
|
+
/** Token description */
|
|
2621
|
+
description: string;
|
|
2622
|
+
/** Token image URI */
|
|
2623
|
+
image?: string;
|
|
2624
|
+
/** External URI for additional metadata */
|
|
2625
|
+
externalUri?: string;
|
|
2626
|
+
/** Additional attributes */
|
|
2627
|
+
attributes?: {
|
|
2628
|
+
trait_type: string;
|
|
2629
|
+
value: string;
|
|
2630
|
+
}[];
|
|
2631
|
+
}
|
|
3052
2632
|
/**
|
|
3053
|
-
*
|
|
3054
|
-
* Pattern: ['a2a_message', session, session.created_at]
|
|
3055
|
-
* NOTE: Fixed to match smart contract expectation - uses session.created_at as little-endian bytes
|
|
2633
|
+
* Metadata pointer configuration
|
|
3056
2634
|
*/
|
|
3057
|
-
|
|
2635
|
+
interface MetadataPointerConfig {
|
|
2636
|
+
/** Authority that can update metadata pointer */
|
|
2637
|
+
authority: Address$1 | null;
|
|
2638
|
+
/** Address where metadata is stored */
|
|
2639
|
+
metadataAddress: Address$1 | null;
|
|
2640
|
+
}
|
|
3058
2641
|
/**
|
|
3059
|
-
*
|
|
3060
|
-
*
|
|
3061
|
-
*
|
|
2642
|
+
* Serialize token metadata for on-chain storage
|
|
2643
|
+
*
|
|
2644
|
+
* @param metadata - Token metadata object
|
|
2645
|
+
* @returns Uint8Array - Serialized metadata
|
|
3062
2646
|
*/
|
|
3063
|
-
declare function
|
|
2647
|
+
declare function serializeTokenMetadata(metadata: TokenMetadata): Uint8Array;
|
|
3064
2648
|
/**
|
|
3065
|
-
*
|
|
3066
|
-
*
|
|
2649
|
+
* Deserialize token metadata from on-chain storage
|
|
2650
|
+
*
|
|
2651
|
+
* @param data - Serialized metadata bytes
|
|
2652
|
+
* @returns TokenMetadata - Parsed metadata object
|
|
3067
2653
|
*/
|
|
3068
|
-
declare function
|
|
2654
|
+
declare function deserializeTokenMetadata(data: Uint8Array): TokenMetadata;
|
|
3069
2655
|
/**
|
|
3070
|
-
*
|
|
3071
|
-
* Pattern: ['agent_verification', agent, verifier]
|
|
2656
|
+
* Token account state options for Token 2022
|
|
3072
2657
|
*/
|
|
3073
|
-
declare
|
|
2658
|
+
declare enum TokenAccountState {
|
|
2659
|
+
/** Account is uninitialized */
|
|
2660
|
+
UNINITIALIZED = 0,
|
|
2661
|
+
/** Account is initialized and usable */
|
|
2662
|
+
INITIALIZED = 1,
|
|
2663
|
+
/** Account is frozen (transfers disabled) */
|
|
2664
|
+
FROZEN = 2
|
|
2665
|
+
}
|
|
3074
2666
|
/**
|
|
3075
|
-
*
|
|
3076
|
-
* Pattern: seeds array with automatic encoding
|
|
2667
|
+
* CPI Guard configuration
|
|
3077
2668
|
*/
|
|
3078
|
-
|
|
3079
|
-
|
|
2669
|
+
interface CpiGuardConfig {
|
|
2670
|
+
/** Whether CPI guard is enabled */
|
|
2671
|
+
enabled: boolean;
|
|
2672
|
+
/** Authority that can toggle CPI guard */
|
|
2673
|
+
authority: Address$1 | null;
|
|
2674
|
+
}
|
|
3080
2675
|
/**
|
|
3081
|
-
*
|
|
3082
|
-
*
|
|
3083
|
-
* Provides wrapper functions for SDK operations that automatically enhance
|
|
3084
|
-
* error messages with detailed instruction account information.
|
|
2676
|
+
* Non-transferable token configuration
|
|
3085
2677
|
*/
|
|
3086
|
-
|
|
2678
|
+
interface NonTransferableConfig {
|
|
2679
|
+
/** Whether the token is non-transferable */
|
|
2680
|
+
nonTransferable: boolean;
|
|
2681
|
+
}
|
|
3087
2682
|
/**
|
|
3088
|
-
*
|
|
2683
|
+
* Immutable owner configuration
|
|
3089
2684
|
*/
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
readonly instructionName?: string;
|
|
3094
|
-
constructor(operation: string, originalError: Error, instructionName?: string);
|
|
2685
|
+
interface ImmutableOwnerConfig {
|
|
2686
|
+
/** Whether the account has immutable owner */
|
|
2687
|
+
immutable: boolean;
|
|
3095
2688
|
}
|
|
3096
2689
|
/**
|
|
3097
|
-
*
|
|
2690
|
+
* Check if account state allows transfers
|
|
2691
|
+
*
|
|
2692
|
+
* @param state - Current account state
|
|
2693
|
+
* @param isNonTransferable - Whether token is non-transferable
|
|
2694
|
+
* @param isFrozen - Whether account is frozen
|
|
2695
|
+
* @returns boolean - True if transfers are allowed
|
|
3098
2696
|
*/
|
|
3099
|
-
|
|
3100
|
-
address: Address$1;
|
|
3101
|
-
name?: string;
|
|
3102
|
-
};
|
|
2697
|
+
declare function canTransfer(state: TokenAccountState, isNonTransferable?: boolean, isFrozen?: boolean): boolean;
|
|
3103
2698
|
/**
|
|
3104
|
-
*
|
|
2699
|
+
* Get required extensions for account creation
|
|
2700
|
+
*
|
|
2701
|
+
* @param extensions - Desired extensions
|
|
2702
|
+
* @returns TokenExtension[] - Required extensions in dependency order
|
|
3105
2703
|
*/
|
|
3106
|
-
declare function
|
|
2704
|
+
declare function getRequiredExtensions(extensions: TokenExtension[]): TokenExtension[];
|
|
3107
2705
|
/**
|
|
3108
|
-
*
|
|
2706
|
+
* Convert basis points to percentage
|
|
2707
|
+
*
|
|
2708
|
+
* @param basisPoints - Basis points (10000 = 100%)
|
|
2709
|
+
* @returns number - Percentage as decimal (1.0 = 100%)
|
|
3109
2710
|
*/
|
|
3110
|
-
declare function
|
|
2711
|
+
declare function basisPointsToPercentage(basisPoints: number): number;
|
|
3111
2712
|
/**
|
|
3112
|
-
*
|
|
2713
|
+
* Convert percentage to basis points
|
|
2714
|
+
*
|
|
2715
|
+
* @param percentage - Percentage as decimal (1.0 = 100%)
|
|
2716
|
+
* @returns number - Basis points
|
|
3113
2717
|
*/
|
|
3114
|
-
declare function
|
|
2718
|
+
declare function percentageToBasisPoints(percentage: number): number;
|
|
3115
2719
|
/**
|
|
3116
|
-
*
|
|
2720
|
+
* Format basis points as readable percentage
|
|
2721
|
+
*
|
|
2722
|
+
* @param basisPoints - Basis points
|
|
2723
|
+
* @returns string - Formatted percentage (e.g., "2.50%")
|
|
3117
2724
|
*/
|
|
3118
|
-
declare function
|
|
3119
|
-
operation?: string;
|
|
3120
|
-
instructionName?: string;
|
|
3121
|
-
accounts?: AccountContext[];
|
|
3122
|
-
params?: Record<string, unknown>;
|
|
3123
|
-
}): void;
|
|
2725
|
+
declare function formatBasisPoints(basisPoints: number): string;
|
|
3124
2726
|
/**
|
|
3125
|
-
*
|
|
2727
|
+
* Estimate gas costs for Token 2022 operations
|
|
2728
|
+
*
|
|
2729
|
+
* @param operation - Type of operation
|
|
2730
|
+
* @param extensions - Extensions involved
|
|
2731
|
+
* @returns bigint - Estimated compute units
|
|
3126
2732
|
*/
|
|
3127
|
-
|
|
3128
|
-
operation: string;
|
|
3129
|
-
instructionName?: string;
|
|
3130
|
-
accounts?: AccountContext[];
|
|
3131
|
-
params?: Record<string, unknown>;
|
|
3132
|
-
}
|
|
2733
|
+
declare function estimateComputeUnits(operation: 'transfer' | 'create_account' | 'mint' | 'burn', extensions?: TokenExtension[]): bigint;
|
|
3133
2734
|
/**
|
|
3134
|
-
* Create
|
|
2735
|
+
* Create transfer fee configuration with validation
|
|
3135
2736
|
*/
|
|
3136
|
-
declare function
|
|
2737
|
+
declare function createTransferFeeConfig(params: {
|
|
2738
|
+
transferFeeBasisPoints: number;
|
|
2739
|
+
maximumFee: bigint;
|
|
2740
|
+
transferFeeConfigAuthority: Address$1 | null;
|
|
2741
|
+
withdrawWithheldAuthority: Address$1 | null;
|
|
2742
|
+
}): TransferFeeConfig;
|
|
3137
2743
|
/**
|
|
3138
|
-
*
|
|
2744
|
+
* Create interest bearing configuration with validation
|
|
3139
2745
|
*/
|
|
3140
|
-
declare function
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
}[]): void;
|
|
2746
|
+
declare function createInterestBearingConfig(params: {
|
|
2747
|
+
rateAuthority: Address$1 | null;
|
|
2748
|
+
currentRate: number;
|
|
2749
|
+
}): InterestBearingConfig;
|
|
3145
2750
|
/**
|
|
3146
|
-
*
|
|
2751
|
+
* Parse token extension data from raw bytes
|
|
3147
2752
|
*/
|
|
3148
|
-
declare function
|
|
2753
|
+
declare function parseTokenExtension(extensionType: 'TransferFeeConfig' | 'InterestBearingConfig' | string, data: Uint8Array): TransferFeeConfig | InterestBearingConfig;
|
|
2754
|
+
|
|
2755
|
+
type token2022Extensions_ConfidentialAccountState = ConfidentialAccountState;
|
|
2756
|
+
type token2022Extensions_ConfidentialTransferProof = ConfidentialTransferProof;
|
|
2757
|
+
type token2022Extensions_CpiGuardConfig = CpiGuardConfig;
|
|
2758
|
+
type token2022Extensions_ImmutableOwnerConfig = ImmutableOwnerConfig;
|
|
2759
|
+
type token2022Extensions_InterestCalculation = InterestCalculation;
|
|
2760
|
+
type token2022Extensions_MetadataPointerConfig = MetadataPointerConfig;
|
|
2761
|
+
type token2022Extensions_NonTransferableConfig = NonTransferableConfig;
|
|
2762
|
+
type token2022Extensions_TokenAccountState = TokenAccountState;
|
|
2763
|
+
declare const token2022Extensions_TokenAccountState: typeof TokenAccountState;
|
|
2764
|
+
type token2022Extensions_TokenMetadata = TokenMetadata;
|
|
2765
|
+
type token2022Extensions_TransferFeeCalculation = TransferFeeCalculation;
|
|
2766
|
+
type token2022Extensions_TransferFeeConfig = TransferFeeConfig;
|
|
2767
|
+
type token2022Extensions_TransferHookContext = TransferHookContext;
|
|
2768
|
+
type token2022Extensions_TransferHookInstruction = TransferHookInstruction;
|
|
2769
|
+
declare const token2022Extensions_basisPointsToPercentage: typeof basisPointsToPercentage;
|
|
2770
|
+
declare const token2022Extensions_calculateCompoundInterest: typeof calculateCompoundInterest;
|
|
2771
|
+
declare const token2022Extensions_calculateInterest: typeof calculateInterest;
|
|
2772
|
+
declare const token2022Extensions_calculateRequiredAmountForNetTransfer: typeof calculateRequiredAmountForNetTransfer;
|
|
2773
|
+
declare const token2022Extensions_calculateTransferFee: typeof calculateTransferFee;
|
|
2774
|
+
declare const token2022Extensions_canTransfer: typeof canTransfer;
|
|
2775
|
+
declare const token2022Extensions_createInterestBearingConfig: typeof createInterestBearingConfig;
|
|
2776
|
+
declare const token2022Extensions_createTransferFeeConfig: typeof createTransferFeeConfig;
|
|
2777
|
+
declare const token2022Extensions_createTransferHookInstruction: typeof createTransferHookInstruction;
|
|
2778
|
+
declare const token2022Extensions_deserializeTokenMetadata: typeof deserializeTokenMetadata;
|
|
2779
|
+
declare const token2022Extensions_estimateAccumulatedFees: typeof estimateAccumulatedFees;
|
|
2780
|
+
declare const token2022Extensions_estimateComputeUnits: typeof estimateComputeUnits;
|
|
2781
|
+
declare const token2022Extensions_formatBasisPoints: typeof formatBasisPoints;
|
|
2782
|
+
declare const token2022Extensions_generateConfidentialTransferProof: typeof generateConfidentialTransferProof;
|
|
2783
|
+
declare const token2022Extensions_getRequiredExtensions: typeof getRequiredExtensions;
|
|
2784
|
+
declare const token2022Extensions_parseTokenExtension: typeof parseTokenExtension;
|
|
2785
|
+
declare const token2022Extensions_percentageToBasisPoints: typeof percentageToBasisPoints;
|
|
2786
|
+
declare const token2022Extensions_serializeTokenMetadata: typeof serializeTokenMetadata;
|
|
2787
|
+
declare const token2022Extensions_validateTransferHookInstruction: typeof validateTransferHookInstruction;
|
|
2788
|
+
declare const token2022Extensions_verifyConfidentialTransferProof: typeof verifyConfidentialTransferProof;
|
|
2789
|
+
declare namespace token2022Extensions {
|
|
2790
|
+
export { type token2022Extensions_ConfidentialAccountState as ConfidentialAccountState, type token2022Extensions_ConfidentialTransferProof as ConfidentialTransferProof, type token2022Extensions_CpiGuardConfig as CpiGuardConfig, type token2022Extensions_ImmutableOwnerConfig as ImmutableOwnerConfig, type token2022Extensions_InterestCalculation as InterestCalculation, type token2022Extensions_MetadataPointerConfig as MetadataPointerConfig, type token2022Extensions_NonTransferableConfig as NonTransferableConfig, token2022Extensions_TokenAccountState as TokenAccountState, type token2022Extensions_TokenMetadata as TokenMetadata, type token2022Extensions_TransferFeeCalculation as TransferFeeCalculation, type token2022Extensions_TransferFeeConfig as TransferFeeConfig, type token2022Extensions_TransferHookContext as TransferHookContext, type token2022Extensions_TransferHookInstruction as TransferHookInstruction, token2022Extensions_basisPointsToPercentage as basisPointsToPercentage, token2022Extensions_calculateCompoundInterest as calculateCompoundInterest, token2022Extensions_calculateInterest as calculateInterest, token2022Extensions_calculateRequiredAmountForNetTransfer as calculateRequiredAmountForNetTransfer, token2022Extensions_calculateTransferFee as calculateTransferFee, token2022Extensions_canTransfer as canTransfer, token2022Extensions_createInterestBearingConfig as createInterestBearingConfig, token2022Extensions_createTransferFeeConfig as createTransferFeeConfig, token2022Extensions_createTransferHookInstruction as createTransferHookInstruction, token2022Extensions_deserializeTokenMetadata as deserializeTokenMetadata, token2022Extensions_estimateAccumulatedFees as estimateAccumulatedFees, token2022Extensions_estimateComputeUnits as estimateComputeUnits, token2022Extensions_formatBasisPoints as formatBasisPoints, token2022Extensions_generateConfidentialTransferProof as generateConfidentialTransferProof, token2022Extensions_getRequiredExtensions as getRequiredExtensions, token2022Extensions_parseTokenExtension as parseTokenExtension, token2022Extensions_percentageToBasisPoints as percentageToBasisPoints, token2022Extensions_serializeTokenMetadata as serializeTokenMetadata, token2022Extensions_validateTransferHookInstruction as validateTransferHookInstruction, token2022Extensions_verifyConfidentialTransferProof as verifyConfidentialTransferProof };
|
|
2791
|
+
}
|
|
3149
2792
|
|
|
3150
2793
|
/**
|
|
3151
2794
|
* Governance Helper Utilities
|
|
@@ -3805,7 +3448,7 @@ declare enum ProofMode {
|
|
|
3805
3448
|
}
|
|
3806
3449
|
interface ProofGenerationOptions {
|
|
3807
3450
|
mode?: ProofMode;
|
|
3808
|
-
connection?:
|
|
3451
|
+
connection?: Rpc<GetAccountInfoApi>;
|
|
3809
3452
|
}
|
|
3810
3453
|
/**
|
|
3811
3454
|
* Generate a range proof with proper commitment handling
|
|
@@ -3827,11 +3470,11 @@ declare function generateTransferProofWithInstruction(sourceBalance: ElGamalCiph
|
|
|
3827
3470
|
/**
|
|
3828
3471
|
* Check if ZK program is available
|
|
3829
3472
|
*/
|
|
3830
|
-
declare function isZkProgramAvailable(connection?:
|
|
3473
|
+
declare function isZkProgramAvailable(connection?: Rpc<GetAccountInfoApi>): Promise<boolean>;
|
|
3831
3474
|
/**
|
|
3832
3475
|
* Get ZK program status message
|
|
3833
3476
|
*/
|
|
3834
|
-
declare function getZkProgramStatus(connection?:
|
|
3477
|
+
declare function getZkProgramStatus(connection?: Rpc<GetAccountInfoApi>): Promise<string>;
|
|
3835
3478
|
|
|
3836
3479
|
/**
|
|
3837
3480
|
* Confidential Transfer Manager
|
|
@@ -3936,12 +3579,12 @@ interface TransferParams {
|
|
|
3936
3579
|
proofMode?: ProofMode;
|
|
3937
3580
|
}
|
|
3938
3581
|
declare class ConfidentialTransferManager {
|
|
3939
|
-
private
|
|
3582
|
+
private rpc;
|
|
3940
3583
|
private defaultProofMode;
|
|
3941
3584
|
private clientEncryption;
|
|
3942
3585
|
private metadataStorage;
|
|
3943
3586
|
private featureFlags;
|
|
3944
|
-
constructor(
|
|
3587
|
+
constructor(rpc: Rpc<GetAccountInfoApi>, defaultProofMode?: ProofMode);
|
|
3945
3588
|
/**
|
|
3946
3589
|
* Get the current privacy mode status
|
|
3947
3590
|
*/
|
|
@@ -4000,11 +3643,11 @@ declare class ConfidentialTransferManager {
|
|
|
4000
3643
|
*/
|
|
4001
3644
|
private generateZeroBalanceProof;
|
|
4002
3645
|
/**
|
|
4003
|
-
* Get account's ElGamal public key
|
|
3646
|
+
* Get account's ElGamal public key from account data
|
|
4004
3647
|
*/
|
|
4005
3648
|
private getAccountElGamalPubkey;
|
|
4006
3649
|
/**
|
|
4007
|
-
* Get encrypted balance
|
|
3650
|
+
* Get encrypted balance from account data
|
|
4008
3651
|
*/
|
|
4009
3652
|
private getEncryptedBalance;
|
|
4010
3653
|
/**
|
|
@@ -4154,4 +3797,4 @@ declare namespace featureFlags {
|
|
|
4154
3797
|
export { featureFlags_DEFAULT_FLAGS as DEFAULT_FLAGS, featureFlags_DEV_FLAGS as DEV_FLAGS, featureFlags_FeatureFlagManager as FeatureFlagManager, type featureFlags_FeatureFlags as FeatureFlags, featureFlags_getFeatureFlags as getFeatureFlags, featureFlags_getPrivacyStatus as getPrivacyStatus, featureFlags_isFeatureEnabled as isFeatureEnabled };
|
|
4155
3798
|
}
|
|
4156
3799
|
|
|
4157
|
-
export {
|
|
3800
|
+
export { deriveJobApplicationPda as $, type AccountInspectionResult as A, createMigrationReport as B, simulateMigration as C, type DiscriminatorValidationResult as D, type ErrorContext as E, getMigrationInstructions as F, GhostSpeakSDKError as G, extractLegacyData as H, IPFSClient as I, type MigrationResult as J, runAccountDiagnostics as K, type LegacyAgentData as L, type MigrationPlan as M, runBatchDiagnostics as N, diagnoseAccountFromChain as O, PrivateMetadataStorage as P, diagnoseBatchFromChain as Q, exportDiagnosticReport as R, type DiagnosticReport as S, TokenProgram as T, type BatchDiagnosticReport as U, deriveA2AMessagePda as V, deriveA2ASessionPda as W, deriveUserRegistryPda as X, deriveWorkOrderPda as Y, type ZkMigrationData as Z, deriveJobPostingPda as _, deriveServiceListingPda as a, LocalStorageProvider as a$, deriveWorkDeliveryPda as a0, derivePaymentPda as a1, deriveServicePurchasePda as a2, deriveAgentVerificationPda as a3, withEnhancedErrorsSync as a4, logEnhancedError as a5, validatePreconditions as a6, extractInstructionName as a7, deriveSplTokenAssociatedTokenAddress as a8, deriveToken2022AssociatedTokenAddress as a9, deserializeTokenMetadata as aA, canTransfer as aB, getRequiredExtensions as aC, basisPointsToPercentage as aD, percentageToBasisPoints as aE, formatBasisPoints as aF, estimateComputeUnits as aG, TokenAccountState as aH, type TransferFeeCalculation as aI, type ConfidentialTransferProof as aJ, type InterestCalculation as aK, type TransferHookInstruction as aL, type TransferHookContext as aM, type TokenMetadata as aN, type MetadataPointerConfig as aO, type CpiGuardConfig as aP, type NonTransferableConfig as aQ, type ImmutableOwnerConfig as aR, deriveMultisigPda as aS, deriveProposalPda as aT, ClientEncryptionService as aU, generateLocalPrivacyProof as aV, verifyLocalPrivacyProof as aW, prepareForZkMigration as aX, type PrivateMetadata as aY, type ClientEncryptionOptions as aZ, MockIPFSProvider as a_, getAssociatedTokenAccount as aa, getAllAssociatedTokenAddresses as ab, validateAssociatedTokenAddress as ac, getTokenProgramAddress as ad, getTokenProgramFromAddress as ae, TokenExtension as af, hasTransferFeeExtension as ag, hasConfidentialTransferExtension as ah, hasInterestBearingExtension as ai, getTransferFeeConfig as aj, getConfidentialTransferConfig as ak, getInterestBearingConfig as al, type AssociatedTokenAccount as am, type TransferFeeConfig as an, type ConfidentialTransferConfig$1 as ao, type InterestBearingConfig as ap, calculateTransferFee as aq, calculateRequiredAmountForNetTransfer as ar, estimateAccumulatedFees as as, generateConfidentialTransferProof as at, verifyConfidentialTransferProof as au, calculateInterest as av, calculateCompoundInterest as aw, validateTransferHookInstruction as ax, createTransferHookInstruction as ay, serializeTokenMetadata as az, deriveAssociatedTokenAddress as b, PrivateDataQuery as b0, estimateStorageCost as b1, createPrivacyManifest as b2, type StorageProvider as b3, type StoredPrivateData as b4, type PrivateDataReference as b5, type PrivacyManifest as b6, ConfidentialTransferManager as b7, type ConfidentialAccount as b8, type ConfigureAccountParams as b9, type DepositParams as ba, type WithdrawParams as bb, type TransferParams as bc, getFeatureFlags as bd, isFeatureEnabled as be, FeatureFlagManager as bf, type FeatureFlags as bg, generateRangeProofWithCommitment as bh, generateTransferProofWithInstruction as bi, isZkProgramAvailable as bj, getZkProgramStatus as bk, ProofMode as bl, type ProofGenerationOptions as bm, type ProofGenerationResult as bn, detectTokenProgram as c, deriveAgentPda as d, formatTokenAmount as e, findProgramDerivedAddress as f, getTokenProgramType as g, enhanceTransactionError as h, isToken2022Mint as i, createErrorContext as j, ipfsClient as k, clientEncryption as l, confidentialTransferManager as m, accountDiagnostics as n, governanceHelpers as o, parseTokenAmount as p, featureFlags as q, type EncryptedData as r, type ElGamalCiphertext as s, token2022Extensions as t, safeDecodeAgent as u, validateAccountDiscriminator as v, withEnhancedErrors as w, createDiscriminatorErrorMessage as x, inspectAccountData as y, createMigrationPlan as z };
|