@domino-sdk/relay 1.68.0 → 1.69.0

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 (77) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/{accounts-DnpKoJCo.d.ts → accounts-DD4gAOCe.d.ts} +25 -3
  3. package/dist/{action-9Xl0StBg.d.ts → action-BDFKqGlH.d.ts} +3 -2
  4. package/dist/{attempt-captures-DMNFMYFb.d.ts → attempt-captures-CbuCmthd.d.ts} +4 -3
  5. package/dist/authoring.d.ts +218 -43
  6. package/dist/authoring.js +73 -17
  7. package/dist/{automatic-outcomes-CQ3vpiQl.d.ts → automatic-outcomes-DE3vfi8g.d.ts} +11 -3
  8. package/dist/avatar.d.ts +2 -1
  9. package/dist/browser.d.ts +15 -14
  10. package/dist/browser.js +11 -11
  11. package/dist/{capability-error-CuI_F7yM.d.ts → capability-error-db7kO8-P.d.ts} +2 -1
  12. package/dist/{catalog-BLGie8Lh.d.ts → catalog-Cf3fHDNn.d.ts} +11 -3
  13. package/dist/{chunk-55WJVFWC.js → chunk-2A3BJ262.js} +2 -2
  14. package/dist/{chunk-P4TPW4SY.js → chunk-5RLIPTL7.js} +1 -1
  15. package/dist/{chunk-HXTKI34N.js → chunk-AZDZEQFK.js} +1 -1
  16. package/dist/{chunk-TYZFVL73.js → chunk-BRROI4CH.js} +4 -4
  17. package/dist/{chunk-6YTSRWRB.js → chunk-CQVKOD3B.js} +71 -4
  18. package/dist/{chunk-MEUAJIVO.js → chunk-CZ23KRVK.js} +2 -2
  19. package/dist/{chunk-DDJN2T5A.js → chunk-DIXYVGXO.js} +1 -1
  20. package/dist/{chunk-75KF633N.js → chunk-GEVARKEV.js} +1 -1
  21. package/dist/{chunk-VRZZB7CQ.js → chunk-LDO5GP7G.js} +1 -1
  22. package/dist/{chunk-SD74HD75.js → chunk-LGGD7S5T.js} +9 -9
  23. package/dist/{chunk-R3MNZKNJ.js → chunk-ME2KUAVJ.js} +1 -1
  24. package/dist/{chunk-DNPDR4Z7.js → chunk-ODJGTFPY.js} +6 -6
  25. package/dist/{chunk-6UBFSMCM.js → chunk-PO2ZDY27.js} +1 -1
  26. package/dist/{chunk-EXZVWQOQ.js → chunk-RKTMSTT7.js} +2 -2
  27. package/dist/{chunk-KKHENO57.js → chunk-SWLW4VN3.js} +2 -2
  28. package/dist/{chunk-CZ7NQ7W7.js → chunk-TCREFRPK.js} +3 -3
  29. package/dist/{chunk-5AKD4ZF3.js → chunk-UGM6DUB2.js} +8 -3
  30. package/dist/{chunk-IW46TW3A.js → chunk-VNEJH4NT.js} +26 -2
  31. package/dist/{chunk-4JSPMFO2.js → chunk-WNEQEDMU.js} +2 -2
  32. package/dist/{chunk-7YSVZA7A.js → chunk-WVK3G2J2.js} +1 -1
  33. package/dist/{client-BMif22WQ.d.ts → client-6eSYOl8h.d.ts} +33 -11
  34. package/dist/{dashboards-DMk-vL1q.d.ts → dashboards-DCOAXL54.d.ts} +6 -5
  35. package/dist/{deployments-BCr418BX.d.ts → deployments-BIfdCMd5.d.ts} +530 -337
  36. package/dist/{host-environment-FN4zg3hw.d.ts → host-environment-DUw5-Cvj.d.ts} +2 -1
  37. package/dist/{identity-integration-r76xaAax.d.ts → identity-integration-BlfOn8rc.d.ts} +3 -2
  38. package/dist/index.d.ts +16 -15
  39. package/dist/index.js +10 -10
  40. package/dist/internal.d.ts +34 -19
  41. package/dist/internal.js +40 -14
  42. package/dist/{limits-ByVRQePO.d.ts → limits-Ctaeq23J.d.ts} +3 -2
  43. package/dist/{offers-xcPbYaEv.d.ts → offers-COqHGbHm.d.ts} +4 -3
  44. package/dist/{participant-activity-DXRq4s6K.d.ts → participant-activity-BznrcePT.d.ts} +2 -1
  45. package/dist/{participant-rewards-BcWkBRn_.d.ts → participant-rewards-s5Gn23qb.d.ts} +23 -1
  46. package/dist/portal-proxy.d.ts +7 -4
  47. package/dist/portal-proxy.js +13 -17
  48. package/dist/profiles-CLDKZVFx.d.ts +370 -0
  49. package/dist/react/index.d.ts +50 -31
  50. package/dist/react/index.js +11 -11
  51. package/dist/{request-error-D_dUPLwo.d.ts → request-error-C24SY7n9.d.ts} +2 -1
  52. package/dist/{reward-deliveries-0VvT6LMj.d.ts → reward-deliveries-DFhYGJdx.d.ts} +3 -2
  53. package/dist/runtime/authoring.js +1 -1
  54. package/dist/runtime/chunks/HKAI5OQA.js +1 -0
  55. package/dist/runtime/manifest.json +3 -3
  56. package/dist/runtime/schema.js +1 -1
  57. package/dist/schema.d.ts +258 -176
  58. package/dist/schema.js +16 -8
  59. package/dist/server/index.d.ts +15 -14
  60. package/dist/server/index.js +45 -45
  61. package/dist/{sign-in-providers-C5_753DZ.d.ts → sign-in-providers-C97mRNbG.d.ts} +4 -3
  62. package/dist/solana.d.ts +142 -26
  63. package/dist/solana.js +449 -114
  64. package/dist/{streaks-0YuipsUQ.d.ts → streaks-MAqKHbHC.d.ts} +2 -1
  65. package/dist/{submission-input-CaL8drIh.d.ts → submission-input-BD7nORuh.d.ts} +4 -3
  66. package/dist/{telegram-browser-DLtHPRBI.d.ts → telegram-browser-gRMgGs7B.d.ts} +8 -7
  67. package/dist/telegram.d.ts +14 -12
  68. package/dist/telegram.js +2 -2
  69. package/dist/testing.d.ts +24 -15
  70. package/dist/testing.js +6 -6
  71. package/dist/{tracker-data-CAK942sx.d.ts → tracker-data-DQgX3FIc.d.ts} +198 -3
  72. package/dist/{transport-CkidqTOk.d.ts → transport-BLU8jrhg.d.ts} +3415 -2233
  73. package/dist/vite.d.ts +2 -1
  74. package/dist/{wallet-DQtJelQQ.d.ts → wallet-CPAjrW4k.d.ts} +52 -375
  75. package/dist/{wallet-browser-dpmr22Xv.d.ts → wallet-browser-BzPt_Qb5.d.ts} +3 -2
  76. package/package.json +6 -3
  77. package/dist/runtime/chunks/2UDZ6TPL.js +0 -1
package/dist/solana.js CHANGED
@@ -1,23 +1,37 @@
1
1
  import {
2
2
  maxCompletionReceipts,
3
3
  walletLinkedEventDataSchema
4
- } from "./chunk-4JSPMFO2.js";
5
- import "./chunk-DNPDR4Z7.js";
6
- import "./chunk-DDJN2T5A.js";
7
- import "./chunk-MEUAJIVO.js";
4
+ } from "./chunk-WNEQEDMU.js";
5
+ import "./chunk-ODJGTFPY.js";
6
+ import "./chunk-DIXYVGXO.js";
7
+ import "./chunk-CZ23KRVK.js";
8
8
  import "./chunk-MWMCQLCG.js";
9
- import "./chunk-R3MNZKNJ.js";
10
- import "./chunk-6UBFSMCM.js";
11
- import "./chunk-55WJVFWC.js";
9
+ import "./chunk-ME2KUAVJ.js";
10
+ import "./chunk-PO2ZDY27.js";
11
+ import "./chunk-2A3BJ262.js";
12
12
  import {
13
13
  paginate,
14
14
  solanaDevnet,
15
15
  solanaMainnet,
16
16
  solanaMemoProgram
17
- } from "./chunk-6YTSRWRB.js";
18
- import "./chunk-IW46TW3A.js";
17
+ } from "./chunk-CQVKOD3B.js";
18
+ import "./chunk-VNEJH4NT.js";
19
19
 
20
20
  // src/solana.ts
21
+ import {
22
+ address as address3,
23
+ generateKeyPairSigner as generateKeyPairSigner2
24
+ } from "@solana/kit";
25
+ import {
26
+ TOKEN_2022_PROGRAM_ADDRESS,
27
+ extension,
28
+ fetchMint,
29
+ findAssociatedTokenPda,
30
+ getCreateMintInstructionPlan,
31
+ getMintToATAInstructionPlan
32
+ } from "@solana-program/token-2022";
33
+
34
+ // src/solana-badge-transactions.ts
21
35
  import {
22
36
  appendTransactionMessageInstructions,
23
37
  createTransactionMessage,
@@ -28,17 +42,388 @@ import {
28
42
  setTransactionMessageFeePayerSigner,
29
43
  setTransactionMessageLifetimeUsingBlockhash,
30
44
  signTransactionMessageWithSigners,
31
- address,
32
- generateKeyPairSigner
45
+ address
33
46
  } from "@solana/kit";
47
+ var memoInstruction = (memo) => ({
48
+ programAddress: address(solanaMemoProgram),
49
+ data: new TextEncoder().encode(memo)
50
+ });
51
+ var instructions = (plan) => flattenInstructionPlan(plan).map((step) => {
52
+ if (step.kind !== "single") {
53
+ throw new Error("Expected a plan of single instructions");
54
+ }
55
+ return step.instruction;
56
+ });
57
+ async function sign(rpc, feePayer, steps) {
58
+ const { value: blockhash } = await rpc.getLatestBlockhash({ commitment: "confirmed" }).send();
59
+ const transaction = await signTransactionMessageWithSigners(
60
+ pipe(
61
+ createTransactionMessage({ version: 0 }),
62
+ (message) => setTransactionMessageFeePayerSigner(feePayer, message),
63
+ (message) => setTransactionMessageLifetimeUsingBlockhash(blockhash, message),
64
+ (message) => appendTransactionMessageInstructions(steps, message)
65
+ )
66
+ );
67
+ return {
68
+ wire: getBase64EncodedWireTransaction(transaction),
69
+ signature: getSignatureFromTransaction(transaction),
70
+ lastValidBlockHeight: blockhash.lastValidBlockHeight
71
+ };
72
+ }
73
+ async function sendAndConfirm(rpc, transaction) {
74
+ try {
75
+ await rpc.sendTransaction(transaction.wire, {
76
+ encoding: "base64",
77
+ preflightCommitment: "confirmed"
78
+ }).send();
79
+ } catch (error) {
80
+ const {
81
+ value: [status]
82
+ } = await rpc.getSignatureStatuses([transaction.signature]).send();
83
+ if (!status) {
84
+ throw error;
85
+ }
86
+ }
87
+ await confirmed(rpc, transaction.signature, transaction.lastValidBlockHeight);
88
+ return transaction.signature;
89
+ }
90
+ async function confirmed(rpc, signature, lastValidBlockHeight) {
91
+ for (; ; ) {
92
+ const {
93
+ value: [status]
94
+ } = await rpc.getSignatureStatuses([signature]).send();
95
+ if (status?.err) {
96
+ throw new Error(
97
+ `Transaction ${signature} failed: ${JSON.stringify(status.err, (_, value) => typeof value === "bigint" ? String(value) : value)}`
98
+ );
99
+ }
100
+ if (status?.confirmationStatus === "confirmed" || status?.confirmationStatus === "finalized") {
101
+ return;
102
+ }
103
+ if (await rpc.getBlockHeight({ commitment: "confirmed" }).send() > lastValidBlockHeight) {
104
+ throw new Error(
105
+ `Transaction ${signature} was not confirmed before its blockhash expired`
106
+ );
107
+ }
108
+ await new Promise((resolve) => setTimeout(resolve, 500));
109
+ }
110
+ }
111
+
112
+ // src/solana-compressed-badges.ts
34
113
  import {
35
- TOKEN_2022_PROGRAM_ADDRESS,
36
- extension,
37
- fetchMint,
38
- findAssociatedTokenPda,
39
- getCreateMintInstructionPlan,
40
- getMintToATAInstructionPlan
41
- } from "@solana-program/token-2022";
114
+ AccountRole,
115
+ addEncoderSizePrefix,
116
+ getAddressDecoder,
117
+ getAddressEncoder,
118
+ getArrayEncoder,
119
+ getBase58Encoder,
120
+ getBooleanEncoder,
121
+ getBytesEncoder,
122
+ fixEncoderSize,
123
+ getNullableEncoder,
124
+ getProgramDerivedAddress,
125
+ getStructEncoder,
126
+ getU16Encoder,
127
+ getU32Encoder,
128
+ getU64Decoder,
129
+ getU64Encoder,
130
+ getU8Encoder,
131
+ getUtf8Encoder,
132
+ address as address2,
133
+ decimalFixedPointToString,
134
+ fetchEncodedAccount,
135
+ generateKeyPairSigner,
136
+ lamports as toLamports,
137
+ lamportsToSol
138
+ } from "@solana/kit";
139
+ var bubblegumProgram = /* @__PURE__ */ (() => address2("BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY"))();
140
+ var coreProgram = /* @__PURE__ */ (() => address2("CoREENxT6tW1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d"))();
141
+ var compressionProgram = /* @__PURE__ */ (() => address2(
142
+ "mcmt6YrQEMKw8Mw43FmpRLmf7BqRnFMKmAcbxE3xkAW"
143
+ ))();
144
+ var noopProgram = /* @__PURE__ */ (() => address2("mnoopTCrg4p8ry25e4bcWA9XZjbNjMTfgYVGGEdRsf3"))();
145
+ var systemProgram = /* @__PURE__ */ (() => address2("11111111111111111111111111111111"))();
146
+ var coreCpiSigner = /* @__PURE__ */ (() => address2("CbNY3JiXdXNE9tPNEk1aRZVEkWdj2v7kfJLNQwZZgpXk"))();
147
+ var string = () => addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder());
148
+ var treeVersion2 = 1;
149
+ var coreCollectionKey = 5;
150
+ var discriminator = () => fixEncoderSize(getBytesEncoder(), 8);
151
+ var readonly = (account) => ({
152
+ address: account,
153
+ role: AccountRole.READONLY
154
+ });
155
+ var writable = (account) => ({
156
+ address: account,
157
+ role: AccountRole.WRITABLE
158
+ });
159
+ var signing = (signer, role) => ({
160
+ address: signer.address,
161
+ role,
162
+ signer
163
+ });
164
+ var treeConfigAddress = async (tree) => (await getProgramDerivedAddress({
165
+ programAddress: bubblegumProgram,
166
+ seeds: [getAddressEncoder().encode(tree)]
167
+ }))[0];
168
+ var mintV2Data = /* @__PURE__ */ (() => getStructEncoder([
169
+ ["discriminator", discriminator()],
170
+ ["name", string()],
171
+ ["symbol", string()],
172
+ ["uri", string()],
173
+ ["sellerFeeBasisPoints", getU16Encoder()],
174
+ ["primarySaleHappened", getBooleanEncoder()],
175
+ ["isMutable", getBooleanEncoder()],
176
+ ["tokenStandard", getNullableEncoder(getU8Encoder())],
177
+ ["creators", getArrayEncoder(getU8Encoder())],
178
+ ["collection", getNullableEncoder(getAddressEncoder())],
179
+ ["assetData", getNullableEncoder(getU8Encoder())],
180
+ ["assetDataSchema", getNullableEncoder(getU8Encoder())]
181
+ ]))();
182
+ async function mintV2(badge, authority, owner) {
183
+ const tree = address2(badge.tree);
184
+ const collection = address2(badge.collection);
185
+ return {
186
+ programAddress: bubblegumProgram,
187
+ accounts: [
188
+ writable(await treeConfigAddress(tree)),
189
+ signing(authority, AccountRole.WRITABLE_SIGNER),
190
+ signing(authority, AccountRole.READONLY_SIGNER),
191
+ signing(authority, AccountRole.READONLY_SIGNER),
192
+ readonly(owner),
193
+ readonly(owner),
194
+ writable(tree),
195
+ writable(collection),
196
+ readonly(coreCpiSigner),
197
+ readonly(noopProgram),
198
+ readonly(compressionProgram),
199
+ readonly(coreProgram),
200
+ readonly(systemProgram)
201
+ ],
202
+ data: mintV2Data.encode({
203
+ discriminator: Uint8Array.of(120, 121, 23, 146, 173, 110, 199, 205),
204
+ name: badge.metadata.name,
205
+ symbol: badge.metadata.symbol ?? "",
206
+ uri: badge.metadata.uri,
207
+ // No royalties: badges are not sold.
208
+ sellerFeeBasisPoints: 0,
209
+ primarySaleHappened: false,
210
+ isMutable: true,
211
+ // TokenStandard::NonFungible, the one Bubblegum accepts.
212
+ tokenStandard: 0,
213
+ creators: [],
214
+ collection,
215
+ assetData: null,
216
+ assetDataSchema: null
217
+ })
218
+ };
219
+ }
220
+ async function checkCompressedBadge(rpc, badge, authority) {
221
+ const tree = address2(badge.tree);
222
+ const collection = address2(badge.collection);
223
+ const read = (account) => fetchEncodedAccount(rpc, account, { commitment: "confirmed" });
224
+ const [config, core] = await Promise.all([
225
+ read(await treeConfigAddress(tree)),
226
+ read(collection)
227
+ ]);
228
+ if (!config.exists || config.programAddress !== bubblegumProgram || config.data.length < 91 || config.data[90] !== treeVersion2) {
229
+ throw new Error(`${tree} is not a Bubblegum v2 tree`);
230
+ }
231
+ if (getAddressDecoder().decode(config.data, 8) !== authority && getAddressDecoder().decode(config.data, 40) !== authority && config.data[88] !== 1) {
232
+ throw new Error(
233
+ `${authority} is neither the creator nor the delegate of ${tree}`
234
+ );
235
+ }
236
+ const capacity = getU64Decoder().decode(config.data, 72);
237
+ if (getU64Decoder().decode(config.data, 80) >= capacity) {
238
+ throw new Error(`${tree} is full: it holds ${capacity} badges`);
239
+ }
240
+ if (!core.exists || core.programAddress !== coreProgram || core.data[0] !== coreCollectionKey) {
241
+ throw new Error(`${collection} is not a Core collection`);
242
+ }
243
+ if (getAddressDecoder().decode(core.data, 1) !== authority) {
244
+ throw new Error(`${authority} is not the update authority of ${collection}`);
245
+ }
246
+ }
247
+ function compressedBadgeMinter(input) {
248
+ return {
249
+ async instructions(owner) {
250
+ await checkCompressedBadge(
251
+ input.rpc,
252
+ input.badge,
253
+ input.authority.address
254
+ );
255
+ return [await mintV2(input.badge, input.authority, owner)];
256
+ },
257
+ async asset(signature) {
258
+ for (let read = 1; ; read++) {
259
+ const asset = await mintedAsset(input.rpc, signature);
260
+ if (asset !== null || read === 5) {
261
+ return asset;
262
+ }
263
+ await new Promise((resolve) => setTimeout(resolve, 500));
264
+ }
265
+ }
266
+ };
267
+ }
268
+ async function mintedAsset(rpc, signature) {
269
+ const transaction = await rpc.getTransaction(signature, {
270
+ commitment: "confirmed",
271
+ encoding: "json",
272
+ maxSupportedTransactionVersion: 0
273
+ }).send();
274
+ if (!transaction) {
275
+ return null;
276
+ }
277
+ const keys = transaction.transaction.message.accountKeys;
278
+ const outer = transaction.transaction.message.instructions.findIndex(
279
+ (instruction) => keys[instruction.programIdIndex] === bubblegumProgram
280
+ );
281
+ const logged = transaction.meta?.innerInstructions?.find((group) => group.index === outer)?.instructions.map((instruction) => ({
282
+ program: keys[instruction.programIdIndex],
283
+ data: getBase58Encoder().encode(instruction.data)
284
+ })).find(
285
+ ({ program, data }) => program === noopProgram && data.length >= 41 && data[0] === 1 && data[1] === 0 && data[6] === 1 && data[7] === 1 && data[8] === 1
286
+ );
287
+ if (!logged) {
288
+ throw new Error(`Transaction ${signature} minted no compressed NFT`);
289
+ }
290
+ return getAddressDecoder().decode(logged.data, 9);
291
+ }
292
+ async function createSolanaBadgeTree(input) {
293
+ const { authority, rpc, maxDepth, maxBufferSize } = input;
294
+ const tree = input.tree ?? await generateKeyPairSigner();
295
+ const collection = input.collectionKey ?? await generateKeyPairSigner();
296
+ const soulbound = !input.collection.transferable;
297
+ const treeBytes = merkleTreeSize(maxDepth, maxBufferSize);
298
+ const collectionBytes = coreCollectionSize(input.collection, soulbound);
299
+ const rents = await Promise.all(
300
+ [treeBytes, treeConfigSize, collectionBytes].map(
301
+ (size) => rpc.getMinimumBalanceForRentExemption(BigInt(size)).send()
302
+ )
303
+ );
304
+ const lamports = toLamports(rents.reduce((sum, rent2) => sum + rent2, 0n));
305
+ const rent = {
306
+ lamports,
307
+ sol: decimalFixedPointToString(lamportsToSol(lamports)),
308
+ capacity: 2 ** maxDepth,
309
+ treeBytes
310
+ };
311
+ const confirm = input.confirmRent ?? ((cost) => {
312
+ console.info(
313
+ `Creating a badge tree for ${cost.capacity} badges and its collection costs ${cost.sol} SOL in rent (${cost.lamports} lamports)`
314
+ );
315
+ return true;
316
+ });
317
+ if (!await confirm(rent)) {
318
+ throw new Error("Badge tree creation was not confirmed; nothing was sent");
319
+ }
320
+ const signature = await sendAndConfirm(
321
+ rpc,
322
+ await sign(rpc, authority, [
323
+ createAccount(authority, tree, rents[0], treeBytes, compressionProgram),
324
+ await createTreeV2(authority, tree.address, maxDepth, maxBufferSize),
325
+ createCollectionV2(authority, collection, input.collection, soulbound)
326
+ ])
327
+ );
328
+ return { tree: tree.address, collection: collection.address, signature };
329
+ }
330
+ var merkleTreeSize = (maxDepth, maxBufferSize) => 1 + (1 + 4 + 4 + 32 + 8 + 1 + 5) + 8 * 3 + maxBufferSize * (32 + 32 * maxDepth + 8) + (32 * maxDepth + 32 + 8);
331
+ var treeConfigSize = 8 + 32 + 32 + 8 + 8 + 1 + 1 + 1 + 5;
332
+ var coreCollectionSize = (collection, soulbound) => {
333
+ const utf8 = (text) => new TextEncoder().encode(text).length;
334
+ const base = 1 + 32 + 4 + utf8(collection.name) + 4 + utf8(collection.uri) + 8;
335
+ let plugins = 1;
336
+ let records = 1 + 33 + 8;
337
+ if (soulbound) {
338
+ plugins += 1 + 1;
339
+ records += 1 + 1 + 8;
340
+ }
341
+ return base + (1 + 8) + plugins + (1 + 4 + records + 4);
342
+ };
343
+ function createAccount(payer, account, lamports, space, owner) {
344
+ return {
345
+ programAddress: systemProgram,
346
+ accounts: [
347
+ signing(payer, AccountRole.WRITABLE_SIGNER),
348
+ signing(account, AccountRole.WRITABLE_SIGNER)
349
+ ],
350
+ data: getStructEncoder([
351
+ ["instruction", getU32Encoder()],
352
+ ["lamports", getU64Encoder()],
353
+ ["space", getU64Encoder()],
354
+ ["owner", getAddressEncoder()]
355
+ ]).encode({ instruction: 0, lamports, space, owner })
356
+ };
357
+ }
358
+ async function createTreeV2(authority, tree, maxDepth, maxBufferSize) {
359
+ return {
360
+ programAddress: bubblegumProgram,
361
+ accounts: [
362
+ writable(await treeConfigAddress(tree)),
363
+ writable(tree),
364
+ signing(authority, AccountRole.WRITABLE_SIGNER),
365
+ signing(authority, AccountRole.READONLY_SIGNER),
366
+ readonly(noopProgram),
367
+ readonly(compressionProgram),
368
+ readonly(systemProgram)
369
+ ],
370
+ data: getStructEncoder([
371
+ ["discriminator", discriminator()],
372
+ ["maxDepth", getU32Encoder()],
373
+ ["maxBufferSize", getU32Encoder()],
374
+ ["public", getNullableEncoder(getBooleanEncoder())]
375
+ ]).encode({
376
+ discriminator: Uint8Array.of(55, 99, 95, 215, 142, 203, 227, 205),
377
+ maxDepth,
378
+ maxBufferSize,
379
+ public: false
380
+ })
381
+ };
382
+ }
383
+ var corePlugin = { permanentFreezeDelegate: 5, bubblegumV2: 15 };
384
+ var corePluginAuthority = { none: 0 };
385
+ function createCollectionV2(authority, collection, details, soulbound) {
386
+ const plugins = [
387
+ Uint8Array.of(corePlugin.bubblegumV2, 0),
388
+ ...soulbound ? [
389
+ Uint8Array.of(
390
+ corePlugin.permanentFreezeDelegate,
391
+ 1,
392
+ // frozen
393
+ 1,
394
+ // Some(
395
+ corePluginAuthority.none
396
+ )
397
+ ] : []
398
+ ];
399
+ return {
400
+ programAddress: coreProgram,
401
+ accounts: [
402
+ signing(collection, AccountRole.WRITABLE_SIGNER),
403
+ readonly(authority.address),
404
+ signing(authority, AccountRole.WRITABLE_SIGNER),
405
+ readonly(systemProgram)
406
+ ],
407
+ data: getStructEncoder([
408
+ ["instruction", getU8Encoder()],
409
+ ["name", string()],
410
+ ["uri", string()],
411
+ ["plugins", getNullableEncoder(getArrayEncoder(getBytesEncoder()))],
412
+ [
413
+ "externalPluginAdapters",
414
+ getNullableEncoder(getArrayEncoder(getU8Encoder()))
415
+ ]
416
+ ]).encode({
417
+ instruction: 21,
418
+ name: details.name,
419
+ uri: details.uri,
420
+ plugins,
421
+ externalPluginAdapters: []
422
+ })
423
+ };
424
+ }
425
+
426
+ // src/solana.ts
42
427
  var solanaBadgeReceiptKey = "badge";
43
428
  async function awardSolanaBadge(input) {
44
429
  const completion = questCompletion(input.event);
@@ -92,9 +477,32 @@ function badgeLookups(input) {
92
477
  }
93
478
  return wallets.get(member)();
94
479
  },
95
- decimals: once(
96
- () => badgeDecimals(input.rpc, address(input.mint), input.authority.address)
97
- )
480
+ minter: input.badge ? compressedBadgeMinter({ ...input, badge: input.badge }) : tokenBadgeMinter(input, address3(input.mint))
481
+ };
482
+ }
483
+ function tokenBadgeMinter(input, mint) {
484
+ let decimals;
485
+ return {
486
+ async instructions(owner) {
487
+ decimals ??= badgeDecimals(input.rpc, mint, input.authority.address);
488
+ const [token] = await findAssociatedTokenPda({
489
+ owner,
490
+ mint,
491
+ tokenProgram: TOKEN_2022_PROGRAM_ADDRESS
492
+ });
493
+ return instructions(
494
+ getMintToATAInstructionPlan({
495
+ payer: input.authority,
496
+ ata: token,
497
+ owner,
498
+ mint,
499
+ mintAuthority: input.authority,
500
+ amount: 1n,
501
+ decimals: await decimals
502
+ })
503
+ );
504
+ },
505
+ asset: async () => mint
98
506
  };
99
507
  }
100
508
  async function awardCompletion(input, completion, lookups) {
@@ -106,14 +514,20 @@ async function awardCompletion(input, completion, lookups) {
106
514
  if (existing) {
107
515
  return { status: "already-minted", receipt: existing };
108
516
  }
109
- const record = (attempt2) => management.completions.recordReceipt(completion.id, {
110
- key: solanaBadgeReceiptKey,
111
- network: attempt2.network,
112
- signature: attempt2.signature,
113
- ...attempt2.asset === null ? {} : { asset: attempt2.asset },
114
- ...attempt2.recipient === null ? {} : { recipient: attempt2.recipient },
115
- ...input.label === void 0 ? {} : { label: input.label }
116
- });
517
+ const record = async (attempt2) => {
518
+ const asset = await lookups.minter.asset(attempt2.signature);
519
+ if (asset === null) {
520
+ throw new SolanaBadgePendingError(attempt2.signature);
521
+ }
522
+ return management.completions.recordReceipt(completion.id, {
523
+ key: solanaBadgeReceiptKey,
524
+ network: attempt2.network,
525
+ signature: attempt2.signature,
526
+ asset,
527
+ ...attempt2.recipient === null ? {} : { recipient: attempt2.recipient },
528
+ ...input.label === void 0 ? {} : { label: input.label }
529
+ });
530
+ };
117
531
  const settled = async () => {
118
532
  const attempt2 = latestAttempt(receipts);
119
533
  const outcome = attempt2 && await attemptOutcome(rpc, attempt2);
@@ -138,26 +552,9 @@ async function awardCompletion(input, completion, lookups) {
138
552
  if (!wallet) {
139
553
  return { status: input.whenNoWallet === "defer" ? "deferred" : "no-wallet" };
140
554
  }
141
- const mint = address(input.mint);
142
- const owner = address(wallet);
143
- const decimals = await lookups.decimals();
144
- const [token] = await findAssociatedTokenPda({
145
- owner,
146
- mint,
147
- tokenProgram: TOKEN_2022_PROGRAM_ADDRESS
148
- });
555
+ const owner = address3(wallet);
149
556
  const transaction = await sign(rpc, authority, [
150
- ...instructions(
151
- getMintToATAInstructionPlan({
152
- payer: authority,
153
- ata: token,
154
- owner,
155
- mint,
156
- mintAuthority: authority,
157
- amount: 1n,
158
- decimals
159
- })
160
- ),
557
+ ...await lookups.minter.instructions(owner),
161
558
  memoInstruction(solanaBadgeMemo(completion.id))
162
559
  ]);
163
560
  let attempt;
@@ -166,7 +563,8 @@ async function awardCompletion(input, completion, lookups) {
166
563
  key: `${attemptPrefix}${next}`,
167
564
  network: input.network,
168
565
  signature: transaction.signature,
169
- asset: mint,
566
+ // A compressed badge's asset ID is known once its mint lands.
567
+ ...input.mint === void 0 ? {} : { asset: input.mint },
170
568
  recipient: owner,
171
569
  label: `Badge mint, valid through block height ${transaction.lastValidBlockHeight}`
172
570
  });
@@ -197,7 +595,7 @@ var SolanaBadgePendingError = class extends Error {
197
595
  };
198
596
  async function createSolanaBadgeMint(input) {
199
597
  const { authority, rpc } = input;
200
- const mint = input.mint ?? await generateKeyPairSigner();
598
+ const mint = input.mint ?? await generateKeyPairSigner2();
201
599
  const plan = await getCreateMintInstructionPlan(
202
600
  {
203
601
  getMinimumBalance: async (space) => rpc.getMinimumBalanceForRentExemption(BigInt(space)).send()
@@ -288,75 +686,12 @@ async function attemptOutcome(rpc, attempt) {
288
686
  }
289
687
  return lastValid === void 0 || height > BigInt(lastValid) ? "expired" : "pending";
290
688
  }
291
- var memoInstruction = (memo) => ({
292
- programAddress: address(solanaMemoProgram),
293
- data: new TextEncoder().encode(memo)
294
- });
295
- var instructions = (plan) => flattenInstructionPlan(plan).map((step) => {
296
- if (step.kind !== "single") {
297
- throw new Error("Expected a plan of single instructions");
298
- }
299
- return step.instruction;
300
- });
301
- async function sign(rpc, feePayer, steps) {
302
- const { value: blockhash } = await rpc.getLatestBlockhash({ commitment: "confirmed" }).send();
303
- const transaction = await signTransactionMessageWithSigners(
304
- pipe(
305
- createTransactionMessage({ version: 0 }),
306
- (message) => setTransactionMessageFeePayerSigner(feePayer, message),
307
- (message) => setTransactionMessageLifetimeUsingBlockhash(blockhash, message),
308
- (message) => appendTransactionMessageInstructions(steps, message)
309
- )
310
- );
311
- return {
312
- wire: getBase64EncodedWireTransaction(transaction),
313
- signature: getSignatureFromTransaction(transaction),
314
- lastValidBlockHeight: blockhash.lastValidBlockHeight
315
- };
316
- }
317
- async function sendAndConfirm(rpc, transaction) {
318
- try {
319
- await rpc.sendTransaction(transaction.wire, {
320
- encoding: "base64",
321
- preflightCommitment: "confirmed"
322
- }).send();
323
- } catch (error) {
324
- const {
325
- value: [status]
326
- } = await rpc.getSignatureStatuses([transaction.signature]).send();
327
- if (!status) {
328
- throw error;
329
- }
330
- }
331
- await confirmed(rpc, transaction.signature, transaction.lastValidBlockHeight);
332
- return transaction.signature;
333
- }
334
- async function confirmed(rpc, signature, lastValidBlockHeight) {
335
- for (; ; ) {
336
- const {
337
- value: [status]
338
- } = await rpc.getSignatureStatuses([signature]).send();
339
- if (status?.err) {
340
- throw new Error(
341
- `Transaction ${signature} failed: ${JSON.stringify(status.err, (_, value) => typeof value === "bigint" ? String(value) : value)}`
342
- );
343
- }
344
- if (status?.confirmationStatus === "confirmed" || status?.confirmationStatus === "finalized") {
345
- return;
346
- }
347
- if (await rpc.getBlockHeight({ commitment: "confirmed" }).send() > lastValidBlockHeight) {
348
- throw new Error(
349
- `Transaction ${signature} was not confirmed before its blockhash expired`
350
- );
351
- }
352
- await new Promise((resolve) => setTimeout(resolve, 500));
353
- }
354
- }
355
689
  export {
356
690
  SolanaBadgePendingError,
357
691
  awardOwedSolanaBadges,
358
692
  awardSolanaBadge,
359
693
  createSolanaBadgeMint,
694
+ createSolanaBadgeTree,
360
695
  solanaBadgeMemo,
361
696
  solanaBadgeReceiptKey,
362
697
  solanaDevnet,
@@ -68,4 +68,5 @@ declare const streakProgressSchema: z.ZodObject<{
68
68
  }, z.core.$strip>;
69
69
  type StreakProgress = z.infer<typeof streakProgressSchema>;
70
70
 
71
- export { type QuizContent as Q, type StreakProgress as S, type StreakPolicy as a, quizContentSchema as b, quizQuestionSchema as c, quizQuestionsSchema as d, streakProgressSchema as e, quizChoiceSchema as q, streakPolicySchema as s };
71
+ export { quizContentSchema as b, quizQuestionSchema as c, quizQuestionsSchema as d, streakProgressSchema as e, quizChoiceSchema as q, streakPolicySchema as s };
72
+ export type { QuizContent as Q, StreakProgress as S, StreakPolicy as a };
@@ -1,6 +1,6 @@
1
1
  import * as z from 'zod';
2
- import { L as LedgerReference, Q as QuestHandle } from './tracker-data-CAK942sx.js';
3
- import { B as ProjectGroupReference } from './accounts-DnpKoJCo.js';
2
+ import { L as LedgerReference, Q as QuestHandle } from './tracker-data-DQgX3FIc.js';
3
+ import { B as ProjectGroupReference } from './accounts-DD4gAOCe.js';
4
4
 
5
5
  declare const completionPrerequisiteSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
6
6
  kind: z.ZodLiteral<"completion">;
@@ -340,4 +340,5 @@ declare function validateSubmissionValue(input: ValueEvidence, contract: {
340
340
  /** Extract an ID only. The URL and its author name are untrusted claims. */
341
341
  declare function xPostId(value: string): string | null;
342
342
 
343
- export { telegramChatsSchema as A, telegramConnectionInputSchema as B, telegramConnectionSchema as C, telegramInitDataSchema as D, telegramMemberInputSchema as E, telegramMessageDataSchema as F, telegramMiniAppSignInSchema as G, telegramReactionDataSchema as H, telegramSignInMethodsSchema as I, textEvidenceSchema as J, textOptionsSchema as K, urlEvidenceSchema as L, type MissingPrerequisite as M, urlOptionsSchema as N, validateSubmissionValue as O, type Prerequisite as P, valueEvidenceSchema as Q, xPostId as R, type TelegramAccountConnection as T, type UrlEvidence as U, type ValueEvidence as V, type TelegramSignInMethods as a, type TextEvidence as b, type TextOptions as c, type UrlOptions as d, type TelegramReader as e, type TelegramChatMember as f, type TelegramChatMemberStatus as g, type TelegramConnection as h, type TelegramMessageData as i, type TelegramReactionData as j, balanceAtLeast as k, completed as l, inGroup as m, type TelegramChat as n, type TelegramChatConnection as o, type TelegramChats as p, balancePrerequisiteSchema as q, completionPrerequisiteSchema as r, groupPrerequisiteSchema as s, missingPrerequisiteSchema as t, prerequisiteSchema as u, telegramAccountConnectionSchema as v, telegramChatConnectionSchema as w, telegramChatIdSchema as x, telegramChatMemberSchema as y, telegramChatSchema as z };
343
+ export { telegramChatsSchema as A, telegramConnectionInputSchema as B, telegramConnectionSchema as C, telegramInitDataSchema as D, telegramMemberInputSchema as E, telegramMessageDataSchema as F, telegramMiniAppSignInSchema as G, telegramReactionDataSchema as H, telegramSignInMethodsSchema as I, textEvidenceSchema as J, textOptionsSchema as K, urlEvidenceSchema as L, urlOptionsSchema as N, validateSubmissionValue as O, valueEvidenceSchema as Q, xPostId as R, balanceAtLeast as k, completed as l, inGroup as m, balancePrerequisiteSchema as q, completionPrerequisiteSchema as r, groupPrerequisiteSchema as s, missingPrerequisiteSchema as t, prerequisiteSchema as u, telegramAccountConnectionSchema as v, telegramChatConnectionSchema as w, telegramChatIdSchema as x, telegramChatMemberSchema as y, telegramChatSchema as z };
344
+ export type { MissingPrerequisite as M, Prerequisite as P, TelegramAccountConnection as T, UrlEvidence as U, ValueEvidence as V, TelegramSignInMethods as a, TextEvidence as b, TextOptions as c, UrlOptions as d, TelegramReader as e, TelegramChatMember as f, TelegramChatMemberStatus as g, TelegramConnection as h, TelegramMessageData as i, TelegramReactionData as j, TelegramChat as n, TelegramChatConnection as o, TelegramChats as p };
@@ -1,9 +1,9 @@
1
- import { c as AuthProvider, J as SignInProvider } from './accounts-DnpKoJCo.js';
2
- import { p as createRelayClient, k as RelayRequestOptions, g as RelayError } from './client-BMif22WQ.js';
3
- import { a as TelegramSignInMethods } from './submission-input-CaL8drIh.js';
4
- import { b as ParticipantSession } from './participant-activity-DXRq4s6K.js';
5
- import { m as WalletSignInNetwork, o as WalletSigner } from './wallet-DQtJelQQ.js';
6
- import { C as CosmosChains } from './wallet-browser-dpmr22Xv.js';
1
+ import { c as AuthProvider, J as SignInProvider } from './accounts-DD4gAOCe.js';
2
+ import { p as createRelayClient, k as RelayRequestOptions, g as RelayError } from './client-6eSYOl8h.js';
3
+ import { a as TelegramSignInMethods } from './submission-input-BD7nORuh.js';
4
+ import { b as ParticipantSession } from './participant-activity-BznrcePT.js';
5
+ import { e as WalletSignInNetwork, g as WalletSigner } from './wallet-CPAjrW4k.js';
6
+ import { C as CosmosChains } from './wallet-browser-BzPt_Qb5.js';
7
7
 
8
8
  type Auth = ReturnType<typeof createRelayClient>["auth"];
9
9
  /**
@@ -184,4 +184,5 @@ declare function signInOptions(relay: SignInClient, input?: {
184
184
  */
185
185
  declare function telegramMiniAppInitData(): string | null;
186
186
 
187
- export { type EmailSignInOption as E, type OAuthSignInOption as O, type ProviderSignInOption as P, type SignInClient as S, type TelegramSignInOption as T, type WalletSignInOption as W, type SignInIcon as a, type SignInMethods as b, type SignInOption as c, type SignInOptions as d, type SignInUnavailable as e, signInOptions as s, telegramMiniAppInitData as t };
187
+ export { signInOptions as s, telegramMiniAppInitData as t };
188
+ export type { EmailSignInOption as E, OAuthSignInOption as O, ProviderSignInOption as P, SignInClient as S, TelegramSignInOption as T, WalletSignInOption as W, SignInIcon as a, SignInMethods as b, SignInOption as c, SignInOptions as d, SignInUnavailable as e };