@ghostspeak/sdk 2.0.6 → 2.0.7

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.
Files changed (117) hide show
  1. package/README.md +152 -30
  2. package/dist/GhostSpeakClient-CWmGaM9Q.d.ts +1007 -0
  3. package/dist/StakingModule-C5rzuOWb.d.ts +2526 -0
  4. package/dist/{agent-M74TCRON.js → agent-5YLZ7DAC.js} +4 -4
  5. package/dist/{agent-M74TCRON.js.map → agent-5YLZ7DAC.js.map} +1 -1
  6. package/dist/batch-operations-45CQFEID.js +4 -0
  7. package/dist/batch-operations-45CQFEID.js.map +1 -0
  8. package/dist/browser.d.ts +45 -554
  9. package/dist/browser.js +15 -842
  10. package/dist/browser.js.map +1 -1
  11. package/dist/chunk-AL3HQN73.js +754 -0
  12. package/dist/chunk-AL3HQN73.js.map +1 -0
  13. package/dist/chunk-BF3IQ35I.js +284 -0
  14. package/dist/chunk-BF3IQ35I.js.map +1 -0
  15. package/dist/chunk-BQDGRTVP.js +168 -0
  16. package/dist/chunk-BQDGRTVP.js.map +1 -0
  17. package/dist/chunk-C5CDA3WX.js +7314 -0
  18. package/dist/chunk-C5CDA3WX.js.map +1 -0
  19. package/dist/chunk-E3FD2CNY.js +1869 -0
  20. package/dist/chunk-E3FD2CNY.js.map +1 -0
  21. package/dist/{chunk-F3DZMBUA.js → chunk-G7S6B6WB.js} +327 -493
  22. package/dist/chunk-G7S6B6WB.js.map +1 -0
  23. package/dist/chunk-IHVDQ4YI.js +4231 -0
  24. package/dist/chunk-IHVDQ4YI.js.map +1 -0
  25. package/dist/chunk-JV2SWONF.js +98 -0
  26. package/dist/chunk-JV2SWONF.js.map +1 -0
  27. package/dist/chunk-KB6CKIUK.js +231 -0
  28. package/dist/chunk-KB6CKIUK.js.map +1 -0
  29. package/dist/chunk-S74EH3KD.js +7890 -0
  30. package/dist/chunk-S74EH3KD.js.map +1 -0
  31. package/dist/chunk-SFTSZ3LC.js +156 -0
  32. package/dist/chunk-SFTSZ3LC.js.map +1 -0
  33. package/dist/chunk-SKMJJ3Q6.js +125 -0
  34. package/dist/chunk-SKMJJ3Q6.js.map +1 -0
  35. package/dist/chunk-SZGFSCNU.js +3682 -0
  36. package/dist/chunk-SZGFSCNU.js.map +1 -0
  37. package/dist/chunk-TTB4OS2D.js +69 -0
  38. package/dist/chunk-TTB4OS2D.js.map +1 -0
  39. package/dist/chunk-UP2VWCW5.js +33 -0
  40. package/dist/{chunk-NSBPE2FW.js.map → chunk-UP2VWCW5.js.map} +1 -1
  41. package/dist/{chunk-UJUGGLMT.js → chunk-VQZQCHUT.js} +5 -5
  42. package/dist/{chunk-UJUGGLMT.js.map → chunk-VQZQCHUT.js.map} +1 -1
  43. package/dist/client.d.ts +5 -4
  44. package/dist/client.js +11 -10
  45. package/dist/createAgentAuthorization-ULG47ZJI.js +5 -0
  46. package/dist/createAgentAuthorization-ULG47ZJI.js.map +1 -0
  47. package/dist/credentials.js +1 -1
  48. package/dist/crypto.js +2 -2
  49. package/dist/errors.js +1 -1
  50. package/dist/feature-flags-B1g0DCPe.d.ts +1181 -0
  51. package/dist/generated-EG5USUFG.js +9 -0
  52. package/dist/{generated-VNLHMR6Y.js.map → generated-EG5USUFG.js.map} +1 -1
  53. package/dist/{ghostspeak_wasm-SB2RPJ3D.js → ghostspeak_wasm-F227HOSM.js} +3 -3
  54. package/dist/{ghostspeak_wasm-SB2RPJ3D.js.map → ghostspeak_wasm-F227HOSM.js.map} +1 -1
  55. package/dist/index.d.ts +1209 -1506
  56. package/dist/index.js +600 -3532
  57. package/dist/index.js.map +1 -1
  58. package/dist/metafile-esm.json +1 -1
  59. package/dist/minimal/core-minimal.d.ts +2383 -1264
  60. package/dist/minimal/core-minimal.js +9 -9
  61. package/dist/minimal/core-minimal.js.map +1 -1
  62. package/dist/nacl-fast-W5BJ3KZ2.js +2229 -0
  63. package/dist/nacl-fast-W5BJ3KZ2.js.map +1 -0
  64. package/dist/pda-4KP7CURF.js +4 -0
  65. package/dist/pda-4KP7CURF.js.map +1 -0
  66. package/dist/pda-Ce7VYg4T.d.ts +25 -0
  67. package/dist/reputation-types-Yebf0Rm_.d.ts +1071 -0
  68. package/dist/revokeAuthorization-OK7E7OK3.js +5 -0
  69. package/dist/revokeAuthorization-OK7E7OK3.js.map +1 -0
  70. package/dist/signature-verification-DGxR4aYQ.d.ts +448 -0
  71. package/dist/types.js +1 -1
  72. package/dist/updateReputationWithAuth-Y4ONEVSP.js +5 -0
  73. package/dist/updateReputationWithAuth-Y4ONEVSP.js.map +1 -0
  74. package/dist/utils.d.ts +69 -203
  75. package/dist/utils.js +15 -153
  76. package/dist/utils.js.map +1 -1
  77. package/package.json +24 -31
  78. package/dist/.tsbuildinfo +0 -1
  79. package/dist/GhostSpeakClient-D_66Uzsf.d.ts +0 -707
  80. package/dist/GovernanceModule-DQYYys-H.d.ts +0 -1766
  81. package/dist/chunk-APCKGD23.js +0 -1328
  82. package/dist/chunk-APCKGD23.js.map +0 -1
  83. package/dist/chunk-ASQXX4IT.js +0 -572
  84. package/dist/chunk-ASQXX4IT.js.map +0 -1
  85. package/dist/chunk-COGZFWOT.js +0 -19657
  86. package/dist/chunk-COGZFWOT.js.map +0 -1
  87. package/dist/chunk-F3DZMBUA.js.map +0 -1
  88. package/dist/chunk-GMHIUK2R.js +0 -7526
  89. package/dist/chunk-GMHIUK2R.js.map +0 -1
  90. package/dist/chunk-IAWBZYPE.js +0 -356
  91. package/dist/chunk-IAWBZYPE.js.map +0 -1
  92. package/dist/chunk-NSBPE2FW.js +0 -15
  93. package/dist/chunk-OWYHJG6H.js +0 -13311
  94. package/dist/chunk-OWYHJG6H.js.map +0 -1
  95. package/dist/chunk-RDDPOFR5.js +0 -3
  96. package/dist/chunk-RDDPOFR5.js.map +0 -1
  97. package/dist/chunk-RERCHKZP.js +0 -35
  98. package/dist/chunk-RERCHKZP.js.map +0 -1
  99. package/dist/chunk-TVVGXYCI.js +0 -2887
  100. package/dist/chunk-TVVGXYCI.js.map +0 -1
  101. package/dist/chunk-ZGP5552B.js +0 -377
  102. package/dist/chunk-ZGP5552B.js.map +0 -1
  103. package/dist/chunk-ZWOYNHVK.js +0 -196
  104. package/dist/chunk-ZWOYNHVK.js.map +0 -1
  105. package/dist/dist/.tsbuildinfo +0 -1
  106. package/dist/elgamal-VZLWB3XK.js +0 -5
  107. package/dist/elgamal-VZLWB3XK.js.map +0 -1
  108. package/dist/feature-flags-V722ZuXO.d.ts +0 -3512
  109. package/dist/generated-VNLHMR6Y.js +0 -5
  110. package/dist/ipfs-types-BOt9ZNg4.d.ts +0 -592
  111. package/dist/multisigConfig-BzEhy6jy.d.ts +0 -58
  112. package/dist/pda-B_nS8SbD.d.ts +0 -114
  113. package/dist/pda-S4BFJVGE.js +0 -4
  114. package/dist/pda-S4BFJVGE.js.map +0 -1
  115. package/dist/system-addresses-BFNLEbFx.d.ts +0 -857
  116. package/dist/token-2022-rpc-RALH4RK7.js +0 -593
  117. package/dist/token-2022-rpc-RALH4RK7.js.map +0 -1
@@ -0,0 +1,156 @@
1
+ import { GHOSTSPEAK_MARKETPLACE_PROGRAM_ADDRESS, expectAddress, expectSome, getAccountMetaFactory } from './chunk-AL3HQN73.js';
2
+ import { fixEncoderSize, getBytesEncoder, transformEncoder, getStructEncoder, getAddressEncoder, getU64Encoder, getI64Encoder, getU8Encoder, getOptionEncoder, addEncoderSizePrefix, getUtf8Encoder, getU32Encoder, getStructDecoder, fixDecoderSize, getAddressDecoder, getU64Decoder, getI64Decoder, getU8Decoder, getOptionDecoder, getBytesDecoder, addDecoderSizePrefix, getUtf8Decoder, getU32Decoder, combineCodec, getProgramDerivedAddress } from '@solana/kit';
3
+
4
+ var CREATE_AGENT_AUTHORIZATION_DISCRIMINATOR = new Uint8Array([
5
+ 48,
6
+ 219,
7
+ 232,
8
+ 202,
9
+ 151,
10
+ 97,
11
+ 230,
12
+ 20
13
+ ]);
14
+ function getCreateAgentAuthorizationDiscriminatorBytes() {
15
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
16
+ CREATE_AGENT_AUTHORIZATION_DISCRIMINATOR
17
+ );
18
+ }
19
+ function getCreateAgentAuthorizationInstructionDataEncoder() {
20
+ return transformEncoder(
21
+ getStructEncoder([
22
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
23
+ ["authorizedSource", getAddressEncoder()],
24
+ ["indexLimit", getU64Encoder()],
25
+ ["expiresAt", getI64Encoder()],
26
+ ["network", getU8Encoder()],
27
+ ["signature", fixEncoderSize(getBytesEncoder(), 64)],
28
+ [
29
+ "nonce",
30
+ getOptionEncoder(
31
+ addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())
32
+ )
33
+ ]
34
+ ]),
35
+ (value) => ({
36
+ ...value,
37
+ discriminator: CREATE_AGENT_AUTHORIZATION_DISCRIMINATOR
38
+ })
39
+ );
40
+ }
41
+ function getCreateAgentAuthorizationInstructionDataDecoder() {
42
+ return getStructDecoder([
43
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
44
+ ["authorizedSource", getAddressDecoder()],
45
+ ["indexLimit", getU64Decoder()],
46
+ ["expiresAt", getI64Decoder()],
47
+ ["network", getU8Decoder()],
48
+ ["signature", fixDecoderSize(getBytesDecoder(), 64)],
49
+ [
50
+ "nonce",
51
+ getOptionDecoder(addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder()))
52
+ ]
53
+ ]);
54
+ }
55
+ function getCreateAgentAuthorizationInstructionDataCodec() {
56
+ return combineCodec(
57
+ getCreateAgentAuthorizationInstructionDataEncoder(),
58
+ getCreateAgentAuthorizationInstructionDataDecoder()
59
+ );
60
+ }
61
+ async function getCreateAgentAuthorizationInstructionAsync(input, config) {
62
+ const programAddress = config?.programAddress ?? GHOSTSPEAK_MARKETPLACE_PROGRAM_ADDRESS;
63
+ const originalAccounts = {
64
+ agent: { value: input.agent ?? null, isWritable: false },
65
+ authorization: { value: input.authorization ?? null, isWritable: true },
66
+ authority: { value: input.authority ?? null, isWritable: true },
67
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
68
+ };
69
+ const accounts = originalAccounts;
70
+ const args = { ...input };
71
+ if (!accounts.authorization.value) {
72
+ accounts.authorization.value = await getProgramDerivedAddress({
73
+ programAddress,
74
+ seeds: [
75
+ getBytesEncoder().encode(
76
+ new Uint8Array([97, 103, 101, 110, 116, 95, 97, 117, 116, 104])
77
+ ),
78
+ getAddressEncoder().encode(expectAddress(accounts.agent.value)),
79
+ getAddressEncoder().encode(expectSome(args.authorizedSource)),
80
+ getOptionEncoder(
81
+ addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())
82
+ ).encode(expectSome(args.nonce))
83
+ ]
84
+ });
85
+ }
86
+ if (!accounts.systemProgram.value) {
87
+ accounts.systemProgram.value = "11111111111111111111111111111111";
88
+ }
89
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
90
+ return Object.freeze({
91
+ accounts: [
92
+ getAccountMeta(accounts.agent),
93
+ getAccountMeta(accounts.authorization),
94
+ getAccountMeta(accounts.authority),
95
+ getAccountMeta(accounts.systemProgram)
96
+ ],
97
+ data: getCreateAgentAuthorizationInstructionDataEncoder().encode(
98
+ args
99
+ ),
100
+ programAddress
101
+ });
102
+ }
103
+ function getCreateAgentAuthorizationInstruction(input, config) {
104
+ const programAddress = config?.programAddress ?? GHOSTSPEAK_MARKETPLACE_PROGRAM_ADDRESS;
105
+ const originalAccounts = {
106
+ agent: { value: input.agent ?? null, isWritable: false },
107
+ authorization: { value: input.authorization ?? null, isWritable: true },
108
+ authority: { value: input.authority ?? null, isWritable: true },
109
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
110
+ };
111
+ const accounts = originalAccounts;
112
+ const args = { ...input };
113
+ if (!accounts.systemProgram.value) {
114
+ accounts.systemProgram.value = "11111111111111111111111111111111";
115
+ }
116
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
117
+ return Object.freeze({
118
+ accounts: [
119
+ getAccountMeta(accounts.agent),
120
+ getAccountMeta(accounts.authorization),
121
+ getAccountMeta(accounts.authority),
122
+ getAccountMeta(accounts.systemProgram)
123
+ ],
124
+ data: getCreateAgentAuthorizationInstructionDataEncoder().encode(
125
+ args
126
+ ),
127
+ programAddress
128
+ });
129
+ }
130
+ function parseCreateAgentAuthorizationInstruction(instruction) {
131
+ if (instruction.accounts.length < 4) {
132
+ throw new Error("Not enough accounts");
133
+ }
134
+ let accountIndex = 0;
135
+ const getNextAccount = () => {
136
+ const accountMeta = instruction.accounts[accountIndex];
137
+ accountIndex += 1;
138
+ return accountMeta;
139
+ };
140
+ return {
141
+ programAddress: instruction.programAddress,
142
+ accounts: {
143
+ agent: getNextAccount(),
144
+ authorization: getNextAccount(),
145
+ authority: getNextAccount(),
146
+ systemProgram: getNextAccount()
147
+ },
148
+ data: getCreateAgentAuthorizationInstructionDataDecoder().decode(
149
+ instruction.data
150
+ )
151
+ };
152
+ }
153
+
154
+ export { CREATE_AGENT_AUTHORIZATION_DISCRIMINATOR, getCreateAgentAuthorizationDiscriminatorBytes, getCreateAgentAuthorizationInstruction, getCreateAgentAuthorizationInstructionAsync, getCreateAgentAuthorizationInstructionDataCodec, getCreateAgentAuthorizationInstructionDataDecoder, getCreateAgentAuthorizationInstructionDataEncoder, parseCreateAgentAuthorizationInstruction };
155
+ //# sourceMappingURL=chunk-SFTSZ3LC.js.map
156
+ //# sourceMappingURL=chunk-SFTSZ3LC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/generated/instructions/createAgentAuthorization.ts"],"names":[],"mappings":";;;AA2DO,IAAM,wCAAA,GAA2C,IAAI,UAAA,CAAW;AAAA,EACrE,EAAA;AAAA,EAAI,GAAA;AAAA,EAAK,GAAA;AAAA,EAAK,GAAA;AAAA,EAAK,GAAA;AAAA,EAAK,EAAA;AAAA,EAAI,GAAA;AAAA,EAAK;AACnC,CAAC;AAEM,SAAS,6CAAA,GAAgD;AAC9D,EAAA,OAAO,cAAA,CAAe,eAAA,EAAgB,EAAG,CAAC,C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CAAY;AAAA;AACd,GACF;AACF","file":"chunk-SFTSZ3LC.js","sourcesContent":["/**\n * This code was AUTOGENERATED using the Codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun Codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n addDecoderSizePrefix,\n addEncoderSizePrefix,\n combineCodec,\n fixDecoderSize,\n fixEncoderSize,\n getAddressDecoder,\n getAddressEncoder,\n getBytesDecoder,\n getBytesEncoder,\n getI64Decoder,\n getI64Encoder,\n getOptionDecoder,\n getOptionEncoder,\n getProgramDerivedAddress,\n getStructDecoder,\n getStructEncoder,\n getU32Decoder,\n getU32Encoder,\n getU64Decoder,\n getU64Encoder,\n getU8Decoder,\n getU8Encoder,\n getUtf8Decoder,\n getUtf8Encoder,\n transformEncoder,\n type AccountMeta,\n type AccountSignerMeta,\n type Address,\n type Codec,\n type Decoder,\n type Encoder,\n type Instruction,\n type InstructionWithAccounts,\n type InstructionWithData,\n type Option,\n type OptionOrNullable,\n type ReadonlyAccount,\n type ReadonlyUint8Array,\n type TransactionSigner,\n type WritableAccount,\n type WritableSignerAccount,\n} from \"@solana/kit\";\nimport { GHOSTSPEAK_MARKETPLACE_PROGRAM_ADDRESS } from \"../programs\";\nimport {\n expectAddress,\n expectSome,\n getAccountMetaFactory,\n type ResolvedAccount,\n} from \"../shared\";\n\nexport const CREATE_AGENT_AUTHORIZATION_DISCRIMINATOR = new Uint8Array([\n 48, 219, 232, 202, 151, 97, 230, 20,\n]);\n\nexport function getCreateAgentAuthorizationDiscriminatorBytes() {\n return fixEncoderSize(getBytesEncoder(), 8).encode(\n CREATE_AGENT_AUTHORIZATION_DISCRIMINATOR,\n );\n}\n\nexport type CreateAgentAuthorizationInstruction<\n TProgram extends string = typeof GHOSTSPEAK_MARKETPLACE_PROGRAM_ADDRESS,\n TAccountAgent extends string | AccountMeta<string> = string,\n TAccountAuthorization extends string | AccountMeta<string> = string,\n TAccountAuthority extends string | AccountMeta<string> = string,\n TAccountSystemProgram extends string | AccountMeta<string> =\n \"11111111111111111111111111111111\",\n TRemainingAccounts extends readonly AccountMeta<string>[] = [],\n> = Instruction<TProgram> &\n InstructionWithData<ReadonlyUint8Array> &\n InstructionWithAccounts<\n [\n TAccountAgent extends string\n ? ReadonlyAccount<TAccountAgent>\n : TAccountAgent,\n TAccountAuthorization extends string\n ? WritableAccount<TAccountAuthorization>\n : TAccountAuthorization,\n TAccountAuthority extends string\n ? WritableSignerAccount<TAccountAuthority> &\n AccountSignerMeta<TAccountAuthority>\n : TAccountAuthority,\n TAccountSystemProgram extends string\n ? ReadonlyAccount<TAccountSystemProgram>\n : TAccountSystemProgram,\n ...TRemainingAccounts,\n ]\n >;\n\nexport type CreateAgentAuthorizationInstructionData = {\n discriminator: ReadonlyUint8Array;\n authorizedSource: Address;\n indexLimit: bigint;\n expiresAt: bigint;\n network: number;\n signature: ReadonlyUint8Array;\n nonce: Option<string>;\n};\n\nexport type CreateAgentAuthorizationInstructionDataArgs = {\n authorizedSource: Address;\n indexLimit: number | bigint;\n expiresAt: number | bigint;\n network: number;\n signature: ReadonlyUint8Array;\n nonce: OptionOrNullable<string>;\n};\n\nexport function getCreateAgentAuthorizationInstructionDataEncoder(): Encoder<CreateAgentAuthorizationInstructionDataArgs> {\n return transformEncoder(\n getStructEncoder([\n [\"discriminator\", fixEncoderSize(getBytesEncoder(), 8)],\n [\"authorizedSource\", getAddressEncoder()],\n [\"indexLimit\", getU64Encoder()],\n [\"expiresAt\", getI64Encoder()],\n [\"network\", getU8Encoder()],\n [\"signature\", fixEncoderSize(getBytesEncoder(), 64)],\n [\n \"nonce\",\n getOptionEncoder(\n addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder()),\n ),\n ],\n ]),\n (value) => ({\n ...value,\n discriminator: CREATE_AGENT_AUTHORIZATION_DISCRIMINATOR,\n }),\n );\n}\n\nexport function getCreateAgentAuthorizationInstructionDataDecoder(): Decoder<CreateAgentAuthorizationInstructionData> {\n return getStructDecoder([\n [\"discriminator\", fixDecoderSize(getBytesDecoder(), 8)],\n [\"authorizedSource\", getAddressDecoder()],\n [\"indexLimit\", getU64Decoder()],\n [\"expiresAt\", getI64Decoder()],\n [\"network\", getU8Decoder()],\n [\"signature\", fixDecoderSize(getBytesDecoder(), 64)],\n [\n \"nonce\",\n getOptionDecoder(addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())),\n ],\n ]);\n}\n\nexport function getCreateAgentAuthorizationInstructionDataCodec(): Codec<\n CreateAgentAuthorizationInstructionDataArgs,\n CreateAgentAuthorizationInstructionData\n> {\n return combineCodec(\n getCreateAgentAuthorizationInstructionDataEncoder(),\n getCreateAgentAuthorizationInstructionDataDecoder(),\n );\n}\n\nexport type CreateAgentAuthorizationAsyncInput<\n TAccountAgent extends string = string,\n TAccountAuthorization extends string = string,\n TAccountAuthority extends string = string,\n TAccountSystemProgram extends string = string,\n> = {\n /** Agent granting authorization */\n agent: Address<TAccountAgent>;\n /** Authorization account (PDA) */\n authorization?: Address<TAccountAuthorization>;\n /** Authority (agent owner) */\n authority: TransactionSigner<TAccountAuthority>;\n /** System program */\n systemProgram?: Address<TAccountSystemProgram>;\n authorizedSource: CreateAgentAuthorizationInstructionDataArgs[\"authorizedSource\"];\n indexLimit: CreateAgentAuthorizationInstructionDataArgs[\"indexLimit\"];\n expiresAt: CreateAgentAuthorizationInstructionDataArgs[\"expiresAt\"];\n network: CreateAgentAuthorizationInstructionDataArgs[\"network\"];\n signature: CreateAgentAuthorizationInstructionDataArgs[\"signature\"];\n nonce: CreateAgentAuthorizationInstructionDataArgs[\"nonce\"];\n};\n\nexport async function getCreateAgentAuthorizationInstructionAsync<\n TAccountAgent extends string,\n TAccountAuthorization extends string,\n TAccountAuthority extends string,\n TAccountSystemProgram extends string,\n TProgramAddress extends Address =\n typeof GHOSTSPEAK_MARKETPLACE_PROGRAM_ADDRESS,\n>(\n input: CreateAgentAuthorizationAsyncInput<\n TAccountAgent,\n TAccountAuthorization,\n TAccountAuthority,\n TAccountSystemProgram\n >,\n config?: { programAddress?: TProgramAddress },\n): Promise<\n CreateAgentAuthorizationInstruction<\n TProgramAddress,\n TAccountAgent,\n TAccountAuthorization,\n TAccountAuthority,\n TAccountSystemProgram\n >\n> {\n // Program address.\n const programAddress =\n config?.programAddress ?? GHOSTSPEAK_MARKETPLACE_PROGRAM_ADDRESS;\n\n // Original accounts.\n const originalAccounts = {\n agent: { value: input.agent ?? null, isWritable: false },\n authorization: { value: input.authorization ?? null, isWritable: true },\n authority: { value: input.authority ?? null, isWritable: true },\n systemProgram: { value: input.systemProgram ?? null, isWritable: false },\n };\n const accounts = originalAccounts as Record<\n keyof typeof originalAccounts,\n ResolvedAccount\n >;\n\n // Original args.\n const args = { ...input };\n\n // Resolve default values.\n if (!accounts.authorization.value) {\n accounts.authorization.value = await getProgramDerivedAddress({\n programAddress,\n seeds: [\n getBytesEncoder().encode(\n new Uint8Array([97, 103, 101, 110, 116, 95, 97, 117, 116, 104]),\n ),\n getAddressEncoder().encode(expectAddress(accounts.agent.value)),\n getAddressEncoder().encode(expectSome(args.authorizedSource)),\n getOptionEncoder(\n addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder()),\n ).encode(expectSome(args.nonce)),\n ],\n });\n }\n if (!accounts.systemProgram.value) {\n accounts.systemProgram.value =\n \"11111111111111111111111111111111\" as Address<\"11111111111111111111111111111111\">;\n }\n\n const getAccountMeta = getAccountMetaFactory(programAddress, \"programId\");\n return Object.freeze({\n accounts: [\n getAccountMeta(accounts.agent),\n getAccountMeta(accounts.authorization),\n getAccountMeta(accounts.authority),\n getAccountMeta(accounts.systemProgram),\n ],\n data: getCreateAgentAuthorizationInstructionDataEncoder().encode(\n args as CreateAgentAuthorizationInstructionDataArgs,\n ),\n programAddress,\n } as CreateAgentAuthorizationInstruction<\n TProgramAddress,\n TAccountAgent,\n TAccountAuthorization,\n TAccountAuthority,\n TAccountSystemProgram\n >);\n}\n\nexport type CreateAgentAuthorizationInput<\n TAccountAgent extends string = string,\n TAccountAuthorization extends string = string,\n TAccountAuthority extends string = string,\n TAccountSystemProgram extends string = string,\n> = {\n /** Agent granting authorization */\n agent: Address<TAccountAgent>;\n /** Authorization account (PDA) */\n authorization: Address<TAccountAuthorization>;\n /** Authority (agent owner) */\n authority: TransactionSigner<TAccountAuthority>;\n /** System program */\n systemProgram?: Address<TAccountSystemProgram>;\n authorizedSource: CreateAgentAuthorizationInstructionDataArgs[\"authorizedSource\"];\n indexLimit: CreateAgentAuthorizationInstructionDataArgs[\"indexLimit\"];\n expiresAt: CreateAgentAuthorizationInstructionDataArgs[\"expiresAt\"];\n network: CreateAgentAuthorizationInstructionDataArgs[\"network\"];\n signature: CreateAgentAuthorizationInstructionDataArgs[\"signature\"];\n nonce: CreateAgentAuthorizationInstructionDataArgs[\"nonce\"];\n};\n\nexport function getCreateAgentAuthorizationInstruction<\n TAccountAgent extends string,\n TAccountAuthorization extends string,\n TAccountAuthority extends string,\n TAccountSystemProgram extends string,\n TProgramAddress extends Address =\n typeof GHOSTSPEAK_MARKETPLACE_PROGRAM_ADDRESS,\n>(\n input: CreateAgentAuthorizationInput<\n TAccountAgent,\n TAccountAuthorization,\n TAccountAuthority,\n TAccountSystemProgram\n >,\n config?: { programAddress?: TProgramAddress },\n): CreateAgentAuthorizationInstruction<\n TProgramAddress,\n TAccountAgent,\n TAccountAuthorization,\n TAccountAuthority,\n TAccountSystemProgram\n> {\n // Program address.\n const programAddress =\n config?.programAddress ?? GHOSTSPEAK_MARKETPLACE_PROGRAM_ADDRESS;\n\n // Original accounts.\n const originalAccounts = {\n agent: { value: input.agent ?? null, isWritable: false },\n authorization: { value: input.authorization ?? null, isWritable: true },\n authority: { value: input.authority ?? null, isWritable: true },\n systemProgram: { value: input.systemProgram ?? null, isWritable: false },\n };\n const accounts = originalAccounts as Record<\n keyof typeof originalAccounts,\n ResolvedAccount\n >;\n\n // Original args.\n const args = { ...input };\n\n // Resolve default values.\n if (!accounts.systemProgram.value) {\n accounts.systemProgram.value =\n \"11111111111111111111111111111111\" as Address<\"11111111111111111111111111111111\">;\n }\n\n const getAccountMeta = getAccountMetaFactory(programAddress, \"programId\");\n return Object.freeze({\n accounts: [\n getAccountMeta(accounts.agent),\n getAccountMeta(accounts.authorization),\n getAccountMeta(accounts.authority),\n getAccountMeta(accounts.systemProgram),\n ],\n data: getCreateAgentAuthorizationInstructionDataEncoder().encode(\n args as CreateAgentAuthorizationInstructionDataArgs,\n ),\n programAddress,\n } as CreateAgentAuthorizationInstruction<\n TProgramAddress,\n TAccountAgent,\n TAccountAuthorization,\n TAccountAuthority,\n TAccountSystemProgram\n >);\n}\n\nexport type ParsedCreateAgentAuthorizationInstruction<\n TProgram extends string = typeof GHOSTSPEAK_MARKETPLACE_PROGRAM_ADDRESS,\n TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],\n> = {\n programAddress: Address<TProgram>;\n accounts: {\n /** Agent granting authorization */\n agent: TAccountMetas[0];\n /** Authorization account (PDA) */\n authorization: TAccountMetas[1];\n /** Authority (agent owner) */\n authority: TAccountMetas[2];\n /** System program */\n systemProgram: TAccountMetas[3];\n };\n data: CreateAgentAuthorizationInstructionData;\n};\n\nexport function parseCreateAgentAuthorizationInstruction<\n TProgram extends string,\n TAccountMetas extends readonly AccountMeta[],\n>(\n instruction: Instruction<TProgram> &\n InstructionWithAccounts<TAccountMetas> &\n InstructionWithData<ReadonlyUint8Array>,\n): ParsedCreateAgentAuthorizationInstruction<TProgram, TAccountMetas> {\n if (instruction.accounts.length < 4) {\n // TODO: Coded error.\n throw new Error(\"Not enough accounts\");\n }\n let accountIndex = 0;\n const getNextAccount = () => {\n const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;\n accountIndex += 1;\n return accountMeta;\n };\n return {\n programAddress: instruction.programAddress,\n accounts: {\n agent: getNextAccount(),\n authorization: getNextAccount(),\n authority: getNextAccount(),\n systemProgram: getNextAccount(),\n },\n data: getCreateAgentAuthorizationInstructionDataDecoder().decode(\n instruction.data,\n ),\n };\n}\n"]}
@@ -0,0 +1,125 @@
1
+ // src/utils/batch-operations.ts
2
+ var MAX_ACCOUNTS_PER_BATCH = 100;
3
+ function chunkArray(array, size) {
4
+ const chunks = [];
5
+ for (let i = 0; i < array.length; i += size) {
6
+ chunks.push(array.slice(i, i + size));
7
+ }
8
+ return chunks;
9
+ }
10
+ async function batchGetAccounts(rpc, addresses, config = {}) {
11
+ const batchSize = Math.min(
12
+ config.batchSize ?? MAX_ACCOUNTS_PER_BATCH,
13
+ MAX_ACCOUNTS_PER_BATCH
14
+ );
15
+ if (addresses.length === 0) return [];
16
+ if (addresses.length <= batchSize) {
17
+ const result = await rpc.getMultipleAccounts(addresses).send();
18
+ return result.value;
19
+ }
20
+ const batches = chunkArray(addresses, batchSize);
21
+ const results = [];
22
+ let completed = 0;
23
+ const batchPromises = batches.map(async (batch) => {
24
+ const result = await rpc.getMultipleAccounts(batch).send();
25
+ completed += batch.length;
26
+ config.onProgress?.(completed, addresses.length);
27
+ return result.value;
28
+ });
29
+ results.push(...await Promise.all(batchPromises));
30
+ return results.flat();
31
+ }
32
+ async function batchGetExistingAccounts(rpc, addresses, config = {}) {
33
+ const accounts = await batchGetAccounts(rpc, addresses, config);
34
+ const existing = [];
35
+ for (let i = 0; i < accounts.length; i++) {
36
+ const account = accounts[i];
37
+ if (account !== null) {
38
+ existing.push({
39
+ address: addresses[i],
40
+ account
41
+ });
42
+ }
43
+ }
44
+ return existing;
45
+ }
46
+ async function batchGetAndMap(rpc, addresses, mapper, config = {}) {
47
+ const accounts = await batchGetAccounts(rpc, addresses, config);
48
+ return accounts.map(
49
+ (account, index) => mapper(account, addresses[index], index)
50
+ );
51
+ }
52
+ async function batchGetAccountsWithRetry(rpc, addresses, config = {}, maxRetries = 3) {
53
+ const batchSize = Math.min(
54
+ config.batchSize ?? MAX_ACCOUNTS_PER_BATCH,
55
+ MAX_ACCOUNTS_PER_BATCH
56
+ );
57
+ if (addresses.length === 0) return [];
58
+ const batches = chunkArray(addresses, batchSize);
59
+ const results = new Array(addresses.length);
60
+ let completed = 0;
61
+ await Promise.all(
62
+ batches.map(async (batch, batchIndex) => {
63
+ let retries = 0;
64
+ let success = false;
65
+ while (!success && retries <= maxRetries) {
66
+ try {
67
+ const result = await rpc.getMultipleAccounts(batch).send();
68
+ const batchResults = result.value;
69
+ batchResults.forEach((account, i) => {
70
+ results[batchIndex * batchSize + i] = account;
71
+ });
72
+ completed += batch.length;
73
+ config.onProgress?.(completed, addresses.length);
74
+ success = true;
75
+ } catch (error) {
76
+ retries++;
77
+ if (retries > maxRetries) {
78
+ throw new Error(
79
+ `Batch ${batchIndex} failed after ${maxRetries} retries: ${error}`
80
+ );
81
+ }
82
+ await new Promise(
83
+ (resolve) => setTimeout(resolve, 100 * Math.pow(2, retries - 1))
84
+ );
85
+ }
86
+ }
87
+ })
88
+ );
89
+ return results;
90
+ }
91
+ function createBatchFetcher(rpc, defaultConfig = {}) {
92
+ return {
93
+ /**
94
+ * Fetch multiple accounts
95
+ */
96
+ getAccounts: (addresses, config) => batchGetAccounts(rpc, addresses, { ...defaultConfig, ...config }),
97
+ /**
98
+ * Fetch only existing accounts
99
+ */
100
+ getExisting: (addresses, config) => batchGetExistingAccounts(rpc, addresses, {
101
+ ...defaultConfig,
102
+ ...config
103
+ }),
104
+ /**
105
+ * Fetch and map accounts
106
+ */
107
+ getAndMap: (addresses, mapper, config) => batchGetAndMap(rpc, addresses, mapper, {
108
+ ...defaultConfig,
109
+ ...config
110
+ }),
111
+ /**
112
+ * Fetch with retry logic
113
+ */
114
+ getWithRetry: (addresses, config, maxRetries) => batchGetAccountsWithRetry(
115
+ rpc,
116
+ addresses,
117
+ { ...defaultConfig, ...config },
118
+ maxRetries
119
+ )
120
+ };
121
+ }
122
+
123
+ export { batchGetAccounts, batchGetAccountsWithRetry, batchGetAndMap, batchGetExistingAccounts, createBatchFetcher };
124
+ //# sourceMappingURL=chunk-SKMJJ3Q6.js.map
125
+ //# sourceMappingURL=chunk-SKMJJ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AAK,GAAA,CAAI,CAAA,EAAG,OAAA,GAAU,CAAC,CAAC;AAAA,WACpD;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAAA,GACH;AAEA,EAAA,OAAO,OAAA;AACT;AAsBO,SAAS,kBAAA,CACd,GAAA,EACA,aAAA,GAAkC,EAAC,EACnC;AACA,EAAA,OAAO;AAAA;AAAA;AAAA;AAAA,IAIL,WAAA,EAAa,CACX,SAAA,EACA,MAAA,KACG,gBAAA,CAAoB,GAAA,EAAK,SAAA,EAAW,EAAE,GAAG,aAAA,EAAe,GAAG,MAAA,EAAQ,CAAA;AAAA;AAAA;AAAA;AAAA,IAKxE,aAAa,CACX,SAAA,EACA,MAAA,KAEA,wBAAA,CAA4B,KAAK,SAAA,EAAW;AAAA,MAC1C,GAAG,aAAA;AAAA,MACH,GAAG;AAAA,KACJ,CAAA;AAAA;AAAA;AAAA;AAAA,IAKH,SAAA,EAAW,CACT,SAAA,EACA,MAAA,EACA,WAEA,cAAA,CAAqB,GAAA,EAAK,WAAW,MAAA,EAAQ;AAAA,MAC3C,GAAG,aAAA;AAAA,MACH,GAAG;AAAA,KACJ,CAAA;AAAA;AAAA;AAAA;AAAA,IAKH,YAAA,EAAc,CACZ,SAAA,EACA,MAAA,EACA,UAAA,KAEA,yBAAA;AAAA,MACE,GAAA;AAAA,MACA,SAAA;AAAA,MACA,EAAE,GAAG,aAAA,EAAe,GAAG,MAAA,EAAO;AAAA,MAC9B;AAAA;AACF,GACJ;AACF","file":"chunk-SKMJJ3Q6.js","sourcesContent":["/**\n * Batch Operations - Efficient multi-account fetching\n *\n * Utilities for batching RPC calls to reduce network overhead.\n * Uses Solana's getMultipleAccounts with 100-account limit.\n *\n * @module batch-operations\n */\n\nimport type { Address } from '@solana/addresses'\nimport type { ExtendedRpcApi } from '../types/index.js'\n\n/**\n * Maximum accounts per getMultipleAccounts call\n * Solana RPC limit is 100 accounts\n */\nconst MAX_ACCOUNTS_PER_BATCH = 100\n\n/**\n * Batch progress callback\n */\nexport type BatchProgressCallback = (completed: number, total: number) => void\n\n/**\n * Batch fetch configuration\n */\nexport interface BatchFetchConfig {\n /** Progress callback for large batches */\n onProgress?: BatchProgressCallback\n /** Batch size (default: 100, max: 100) */\n batchSize?: number\n}\n\n/**\n * Chunk array into smaller batches\n *\n * @param array - Array to chunk\n * @param size - Chunk size (max 100 for RPC calls)\n * @returns Array of chunks\n */\nfunction chunkArray<T>(array: T[], size: number): T[][] {\n const chunks: T[][] = []\n for (let i = 0; i < array.length; i += size) {\n chunks.push(array.slice(i, i + size))\n }\n return chunks\n}\n\n/**\n * Account data type (simplified for RPC returns)\n */\nexport interface AccountData {\n data: Uint8Array | null\n executable: boolean\n lamports: bigint\n owner: Address\n rentEpoch: bigint\n}\n\n/**\n * Batch fetch multiple accounts with automatic chunking\n *\n * Features:\n * - Automatic batching (100 accounts per RPC call)\n * - Parallel batch execution\n * - Progress callback support\n * - Preserves order\n *\n * @param rpc - RPC client\n * @param addresses - Account addresses to fetch\n * @param config - Batch configuration\n * @returns Array of accounts (in same order as input)\n *\n * @example\n * ```typescript\n * const addresses = [...1000 agent addresses...]\n * const accounts = await batchGetAccounts(rpc, addresses, {\n * onProgress: (completed, total) => {\n * console.log(`Fetched ${completed}/${total} accounts`)\n * }\n * })\n * ```\n */\nexport async function batchGetAccounts<T>(\n rpc: ExtendedRpcApi,\n addresses: Address[],\n config: BatchFetchConfig = {}\n): Promise<(T | null)[]> {\n const batchSize = Math.min(\n config.batchSize ?? MAX_ACCOUNTS_PER_BATCH,\n MAX_ACCOUNTS_PER_BATCH\n )\n\n if (addresses.length === 0) return []\n\n // Single batch optimization\n if (addresses.length <= batchSize) {\n const result = await rpc.getMultipleAccounts(addresses).send()\n return result.value as (T | null)[]\n }\n\n // Chunk addresses into batches\n const batches = chunkArray(addresses, batchSize)\n const results: (T | null)[][] = []\n let completed = 0\n\n // Execute all batches in parallel\n const batchPromises = batches.map(async (batch) => {\n const result = await rpc.getMultipleAccounts(batch).send()\n completed += batch.length\n config.onProgress?.(completed, addresses.length)\n return result.value as (T | null)[]\n })\n\n results.push(...(await Promise.all(batchPromises)))\n\n // Flatten results while preserving order\n return results.flat()\n}\n\n/**\n * Batch fetch with filtering (only non-null accounts)\n *\n * Useful when you expect some addresses to not exist.\n *\n * @param rpc - RPC client\n * @param addresses - Account addresses to fetch\n * @param config - Batch configuration\n * @returns Array of non-null accounts with their addresses\n *\n * @example\n * ```typescript\n * const addresses = [...agent addresses...]\n * const existing = await batchGetExistingAccounts(rpc, addresses)\n * // Returns only accounts that exist: [{ address, account }, ...]\n * ```\n */\nexport async function batchGetExistingAccounts<T>(\n rpc: ExtendedRpcApi,\n addresses: Address[],\n config: BatchFetchConfig = {}\n): Promise<Array<{ address: Address; account: T }>> {\n const accounts = await batchGetAccounts<T>(rpc, addresses, config)\n\n const existing: Array<{ address: Address; account: T }> = []\n for (let i = 0; i < accounts.length; i++) {\n const account = accounts[i]\n if (account !== null) {\n existing.push({\n address: addresses[i],\n account,\n })\n }\n }\n\n return existing\n}\n\n/**\n * Batch fetch with mapping\n *\n * Fetches accounts and immediately maps them to a transformed type.\n *\n * @param rpc - RPC client\n * @param addresses - Account addresses to fetch\n * @param mapper - Transform function (account, address, index) => result\n * @param config - Batch configuration\n * @returns Array of mapped results\n *\n * @example\n * ```typescript\n * const agentSummaries = await batchGetAndMap(\n * rpc,\n * agentAddresses,\n * (account, address) => ({\n * address,\n * name: account.data.name,\n * reputation: account.data.totalScore\n * })\n * )\n * ```\n */\nexport async function batchGetAndMap<T, R>(\n rpc: ExtendedRpcApi,\n addresses: Address[],\n mapper: (account: T | null, address: Address, index: number) => R,\n config: BatchFetchConfig = {}\n): Promise<R[]> {\n const accounts = await batchGetAccounts<T>(rpc, addresses, config)\n return accounts.map((account, index) =>\n mapper(account, addresses[index], index)\n )\n}\n\n/**\n * Batch fetch with retry logic\n *\n * Retries failed batches with exponential backoff.\n *\n * @param rpc - RPC client\n * @param addresses - Account addresses to fetch\n * @param config - Batch configuration\n * @param maxRetries - Maximum retry attempts (default: 3)\n * @returns Array of accounts\n */\nexport async function batchGetAccountsWithRetry<T>(\n rpc: ExtendedRpcApi,\n addresses: Address[],\n config: BatchFetchConfig = {},\n maxRetries = 3\n): Promise<(T | null)[]> {\n const batchSize = Math.min(\n config.batchSize ?? MAX_ACCOUNTS_PER_BATCH,\n MAX_ACCOUNTS_PER_BATCH\n )\n\n if (addresses.length === 0) return []\n\n const batches = chunkArray(addresses, batchSize)\n const results: (T | null)[] = new Array(addresses.length)\n let completed = 0\n\n // Execute batches with retry logic\n await Promise.all(\n batches.map(async (batch, batchIndex) => {\n let retries = 0\n let success = false\n\n while (!success && retries <= maxRetries) {\n try {\n const result = await rpc.getMultipleAccounts(batch).send()\n const batchResults = result.value as (T | null)[]\n\n // Insert results at correct indices\n batchResults.forEach((account, i) => {\n results[batchIndex * batchSize + i] = account\n })\n\n completed += batch.length\n config.onProgress?.(completed, addresses.length)\n success = true\n } catch (error) {\n retries++\n if (retries > maxRetries) {\n throw new Error(\n `Batch ${batchIndex} failed after ${maxRetries} retries: ${error}`\n )\n }\n\n // Exponential backoff: 100ms, 200ms, 400ms\n await new Promise((resolve) =>\n setTimeout(resolve, 100 * Math.pow(2, retries - 1))\n )\n }\n }\n })\n )\n\n return results\n}\n\n/**\n * Create a batch fetcher with reusable configuration\n *\n * Factory pattern for creating pre-configured batch fetchers.\n *\n * @param rpc - RPC client\n * @param defaultConfig - Default batch configuration\n * @returns Batch fetcher functions\n *\n * @example\n * ```typescript\n * const fetcher = createBatchFetcher(rpc, {\n * batchSize: 50,\n * onProgress: (c, t) => console.log(`${c}/${t}`)\n * })\n *\n * const accounts = await fetcher.getAccounts(addresses)\n * const existing = await fetcher.getExisting(addresses)\n * ```\n */\nexport function createBatchFetcher(\n rpc: ExtendedRpcApi,\n defaultConfig: BatchFetchConfig = {}\n) {\n return {\n /**\n * Fetch multiple accounts\n */\n getAccounts: <T>(\n addresses: Address[],\n config?: BatchFetchConfig\n ) => batchGetAccounts<T>(rpc, addresses, { ...defaultConfig, ...config }),\n\n /**\n * Fetch only existing accounts\n */\n getExisting: <T>(\n addresses: Address[],\n config?: BatchFetchConfig\n ) =>\n batchGetExistingAccounts<T>(rpc, addresses, {\n ...defaultConfig,\n ...config,\n }),\n\n /**\n * Fetch and map accounts\n */\n getAndMap: <T, R>(\n addresses: Address[],\n mapper: (account: T | null, address: Address, index: number) => R,\n config?: BatchFetchConfig\n ) =>\n batchGetAndMap<T, R>(rpc, addresses, mapper, {\n ...defaultConfig,\n ...config,\n }),\n\n /**\n * Fetch with retry logic\n */\n getWithRetry: <T>(\n addresses: Address[],\n config?: BatchFetchConfig,\n maxRetries?: number\n ) =>\n batchGetAccountsWithRetry<T>(\n rpc,\n addresses,\n { ...defaultConfig, ...config },\n maxRetries\n ),\n }\n}\n"]}