From ceb0eadd9415e8507596b1ef07d7b66fbc83f7c1 Mon Sep 17 00:00:00 2001 From: Bram Borggreve Date: Sun, 7 Apr 2024 06:05:07 +0100 Subject: [PATCH] feat: update tokengator-minter-sdk --- .../src/lib/api-preset-minter.service.ts | 78 +- .../idl/tokengator_minter.json | 471 ++++++++- .../tokengator-minter-exports.ts | 2 +- .../types/tokengator_minter.ts | 980 +++++++++++++++++- .../solana/util/src/lib/tokengator-minter.ts | 5 + 5 files changed, 1459 insertions(+), 77 deletions(-) diff --git a/libs/api/preset/data-access/src/lib/api-preset-minter.service.ts b/libs/api/preset/data-access/src/lib/api-preset-minter.service.ts index e0e59b6..7ce0f15 100644 --- a/libs/api/preset/data-access/src/lib/api-preset-minter.service.ts +++ b/libs/api/preset/data-access/src/lib/api-preset-minter.service.ts @@ -4,7 +4,16 @@ import { Injectable, Logger } from '@nestjs/common' import { Preset } from '@prisma/client' import { ASSOCIATED_TOKEN_PROGRAM_ID, getAssociatedTokenAddressSync, TOKEN_2022_PROGRAM_ID } from '@solana/spl-token' -import { Keypair, PublicKey, SystemProgram, SYSVAR_RENT_PUBKEY } from '@solana/web3.js' +import { + AddressLookupTableProgram, + ComputeBudgetProgram, + Keypair, + PublicKey, + SystemProgram, + SYSVAR_RENT_PUBKEY, + TransactionMessage, + VersionedTransaction, +} from '@solana/web3.js' import { ApiCoreService } from '@tokengator/api-core-data-access' import { ApiSolanaService } from '@tokengator/api-solana-data-access' import { @@ -87,7 +96,47 @@ export class ApiPresetMinterService { const identities = getIdentityProviders([IdentityProvider.Discord]) - const signature = await programTokenMinter.methods + const slot = await this.solana.connection.getSlot('confirmed') + const { blockhash, lastValidBlockHeight } = await this.solana.connection.getLatestBlockhash() + const [createLookupTableIx, lookupTableAccount] = AddressLookupTableProgram.createLookupTable({ + authority: remoteFeePayer.publicKey, + payer: remoteFeePayer.publicKey, + recentSlot: slot - 1, + }) + + const extendLookupTableIx = AddressLookupTableProgram.extendLookupTable({ + addresses: [ + minter, + group, + manager, + minterTokenAccount, + authority.publicKey, + remoteFeePayer.publicKey, + mintKeypair.publicKey, + SYSVAR_RENT_PUBKEY, + WEN_NEW_STANDARD_PROGRAM_ID, + ASSOCIATED_TOKEN_PROGRAM_ID, + TOKEN_2022_PROGRAM_ID, + SystemProgram.programId, + ], + authority: remoteFeePayer.publicKey, + lookupTable: lookupTableAccount, + payer: remoteFeePayer.publicKey, + }) + + const txMessage = new TransactionMessage({ + instructions: [createLookupTableIx, extendLookupTableIx], + payerKey: remoteFeePayer.publicKey, + recentBlockhash: blockhash, + }).compileToV0Message() + + const tx = new VersionedTransaction(txMessage) + tx.sign([remoteFeePayer]) + + const sig = await this.solana.connection.sendTransaction(tx) + await this.solana.connection.confirmTransaction({ blockhash, lastValidBlockHeight, signature: sig }) + + const createMinterWnsIx = await programTokenMinter.methods .createMinterWns({ community: communitySlug, name, @@ -129,10 +178,25 @@ export class ApiPresetMinterService { systemProgram: SystemProgram.programId, }) .signers([authority, mintKeypair, remoteFeePayer]) - .rpc({ commitment: 'confirmed' }) - - this.logger.debug(`Signature: ${signature}`) - return signature + .instruction() + + const { value } = await this.solana.connection.getAddressLookupTable(lookupTableAccount) + + if (value) { + const { blockhash } = await this.solana.connection.getLatestBlockhash() + const transactionMessage = new TransactionMessage({ + instructions: [ComputeBudgetProgram.setComputeUnitLimit({ units: 250_000 }), createMinterWnsIx], + payerKey: remoteFeePayer.publicKey, + recentBlockhash: blockhash, + }).compileToV0Message([value]) + + const transaction = new VersionedTransaction(transactionMessage) + transaction.sign([remoteFeePayer, authority, mintKeypair]) + const signature = await this.solana.connection.sendTransaction(transaction, { skipPreflight: true }) + this.logger.debug(`Signature: ${signature}`) + return signature + } + throw new Error('Lookup table not found') } async mintFromMinter(minterAccount: string, communitySlug: string) { @@ -171,7 +235,7 @@ export class ApiPresetMinterService { ) const signature = await programTokenMinter.methods - .mintMinterWns({ name, symbol, uri }) + .mintMinterWns({ name, symbol, uri, metadata: [] }) .accounts({ minter, group, diff --git a/libs/api/solana/util/src/lib/tokengator-minter-sdk/idl/tokengator_minter.json b/libs/api/solana/util/src/lib/tokengator-minter-sdk/idl/tokengator_minter.json index 2787428..602c4c6 100644 --- a/libs/api/solana/util/src/lib/tokengator-minter-sdk/idl/tokengator_minter.json +++ b/libs/api/solana/util/src/lib/tokengator-minter-sdk/idl/tokengator_minter.json @@ -67,7 +67,9 @@ "name": "group", "isMut": true, "isSigner": false, - "docs": ["WNS ACCOUNTS"] + "docs": [ + "WNS ACCOUNTS" + ] }, { "name": "manager", @@ -78,7 +80,9 @@ "name": "minter", "isMut": true, "isSigner": false, - "docs": [""] + "docs": [ + "" + ] }, { "name": "minterTokenAccount", @@ -135,6 +139,67 @@ } ] }, + { + "name": "addMinterAuthority", + "accounts": [ + { + "name": "minter", + "isMut": true, + "isSigner": false + }, + { + "name": "authority", + "isMut": false, + "isSigner": true + }, + { + "name": "feePayer", + "isMut": true, + "isSigner": true + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "AddMinterAuthorityArgs" + } + } + ] + }, + { + "name": "removeMinterAuthority", + "accounts": [ + { + "name": "minter", + "isMut": true, + "isSigner": false + }, + { + "name": "feePayer", + "isMut": true, + "isSigner": true + }, + { + "name": "authority", + "isMut": false, + "isSigner": true + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "RemoveMinterAuthorityArgs" + } + } + ] + }, { "name": "mintMinterWns", "accounts": [ @@ -142,7 +207,9 @@ "name": "manager", "isMut": false, "isSigner": false, - "docs": ["WNS ACCOUNTS"] + "docs": [ + "WNS ACCOUNTS" + ] }, { "name": "group", @@ -158,7 +225,9 @@ "name": "minter", "isMut": true, "isSigner": false, - "docs": [""] + "docs": [ + "" + ] }, { "name": "mint", @@ -214,9 +283,245 @@ } } ] + }, + { + "name": "updateMemberMetdata", + "accounts": [ + { + "name": "minter", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "UpdateMemberMetadataArgs" + } + } + ] + }, + { + "name": "updateMemberMetadataWns", + "accounts": [ + { + "name": "minter", + "isMut": true, + "isSigner": false + }, + { + "name": "group", + "isMut": false, + "isSigner": false + }, + { + "name": "member", + "isMut": false, + "isSigner": false + }, + { + "name": "mint", + "isMut": true, + "isSigner": false + }, + { + "name": "feePayer", + "isMut": true, + "isSigner": true + }, + { + "name": "wnsProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "UpdateMemberMetadataWNSArgs" + } + } + ] + }, + { + "name": "removeMinter", + "accounts": [ + { + "name": "minter", + "isMut": true, + "isSigner": false + }, + { + "name": "mint", + "isMut": true, + "isSigner": false + }, + { + "name": "feePayer", + "isMut": true, + "isSigner": true + }, + { + "name": "authority", + "isMut": false, + "isSigner": true + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "associatedTokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "createActivity", + "accounts": [ + { + "name": "activity", + "isMut": true, + "isSigner": false + }, + { + "name": "minter", + "isMut": false, + "isSigner": false + }, + { + "name": "group", + "isMut": false, + "isSigner": false + }, + { + "name": "member", + "isMut": false, + "isSigner": false + }, + { + "name": "mint", + "isMut": false, + "isSigner": false + }, + { + "name": "feePayer", + "isMut": true, + "isSigner": true + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "CreateActivityArgs" + } + } + ] + }, + { + "name": "appendActivityEntry", + "accounts": [ + { + "name": "activity", + "isMut": true, + "isSigner": false + }, + { + "name": "feePayer", + "isMut": true, + "isSigner": true + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "AppendActivityEntryArgs" + } + } + ] } ], "accounts": [ + { + "name": "Activity", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "label", + "type": "string" + }, + { + "name": "startDate", + "type": "i64" + }, + { + "name": "endDate", + "type": "i64" + }, + { + "name": "feePayer", + "type": "publicKey" + }, + { + "name": "minter", + "type": "publicKey" + }, + { + "name": "member", + "type": "publicKey" + }, + { + "name": "mint", + "type": "publicKey" + }, + { + "name": "entries", + "type": { + "vec": { + "defined": "Entry" + } + } + } + ] + } + }, { "name": "Group", "type": { @@ -254,6 +559,10 @@ "name": "communityId", "type": "publicKey" }, + { + "name": "group", + "type": "publicKey" + }, { "name": "name", "type": "string" @@ -294,7 +603,61 @@ ], "types": [ { - "name": "AddPresetAuthorityArgs", + "name": "AppendActivityEntryArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "timestamp", + "type": { + "option": "i64" + } + }, + { + "name": "message", + "type": "string" + }, + { + "name": "url", + "type": { + "option": "string" + } + }, + { + "name": "points", + "type": { + "option": "u8" + } + } + ] + } + }, + { + "name": "CreateActivityArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "label", + "type": "string" + }, + { + "name": "startDate", + "type": { + "option": "i64" + } + }, + { + "name": "endDate", + "type": { + "option": "i64" + } + } + ] + } + }, + { + "name": "AddMinterAuthorityArgs", "type": { "kind": "struct", "fields": [ @@ -306,7 +669,19 @@ } }, { - "name": "CreateMinterWNSArgs", + "name": "RemoveMinterAuthorityArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "authorityToRemove", + "type": "publicKey" + } + ] + } + }, + { + "name": "CreateMinterArgs", "type": { "kind": "struct", "fields": [ @@ -364,7 +739,31 @@ } }, { - "name": "CreateMinterArgs", + "name": "UpdateMemberMetadataArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "label", + "type": "string" + }, + { + "name": "startDate", + "type": { + "option": "i64" + } + }, + { + "name": "endDate", + "type": { + "option": "i64" + } + } + ] + } + }, + { + "name": "CreateMinterWNSArgs", "type": { "kind": "struct", "fields": [ @@ -437,18 +836,61 @@ { "name": "uri", "type": "string" + }, + { + "name": "metadata", + "type": { + "option": { + "vec": { + "array": [ + "string", + 2 + ] + } + } + } } ] } }, { - "name": "RemovePresetAuthorityArgs", + "name": "UpdateMemberMetadataWNSArgs", "type": { "kind": "struct", "fields": [ { - "name": "authorityToRemove", - "type": "publicKey" + "name": "field", + "type": "string" + }, + { + "name": "newValue", + "type": "string" + } + ] + } + }, + { + "name": "Entry", + "type": { + "kind": "struct", + "fields": [ + { + "name": "timestamp", + "type": "i64" + }, + { + "name": "message", + "type": "string" + }, + { + "name": "url", + "type": { + "option": "string" + } + }, + { + "name": "points", + "type": "u8" } ] } @@ -499,7 +941,10 @@ "type": { "option": { "vec": { - "array": ["string", 2] + "array": [ + "string", + 2 + ] } } } @@ -715,6 +1160,6 @@ } ], "metadata": { - "address": "gatorxhhdfsTpfkgB2QM4qwkwgSem2UgzPXLaD2ZGoY" + "address": "GAToRDEEZmbXSe7ECcChQ1TsZCQXDBCtVhSd1Ypas9h6" } -} +} \ No newline at end of file diff --git a/libs/api/solana/util/src/lib/tokengator-minter-sdk/tokengator-minter-exports.ts b/libs/api/solana/util/src/lib/tokengator-minter-sdk/tokengator-minter-exports.ts index 062944a..1c863fc 100644 --- a/libs/api/solana/util/src/lib/tokengator-minter-sdk/tokengator-minter-exports.ts +++ b/libs/api/solana/util/src/lib/tokengator-minter-sdk/tokengator-minter-exports.ts @@ -7,7 +7,7 @@ import { IDL as TokengatorMinterIDL } from './types/tokengator_minter' export { TokengatorMinter, TokengatorMinterIDL } // After updating your program ID (e.g. after running `anchor keys sync`) update the value below. -export const TOKENGATOR_MINTER_PROGRAM_ID = new PublicKey('gatorxhhdfsTpfkgB2QM4qwkwgSem2UgzPXLaD2ZGoY') +export const TOKENGATOR_MINTER_PROGRAM_ID = new PublicKey('GAToRDEEZmbXSe7ECcChQ1TsZCQXDBCtVhSd1Ypas9h6') // This is a helper function to get the program ID for the TokengatorMinter program depending on the cluster. export function getTokengatorMinterProgramId(cluster: Cluster) { diff --git a/libs/api/solana/util/src/lib/tokengator-minter-sdk/types/tokengator_minter.ts b/libs/api/solana/util/src/lib/tokengator-minter-sdk/types/tokengator_minter.ts index a7d0614..6a2a66b 100644 --- a/libs/api/solana/util/src/lib/tokengator-minter-sdk/types/tokengator_minter.ts +++ b/libs/api/solana/util/src/lib/tokengator-minter-sdk/types/tokengator_minter.ts @@ -139,6 +139,67 @@ export type TokengatorMinter = { } ] }, + { + "name": "addMinterAuthority", + "accounts": [ + { + "name": "minter", + "isMut": true, + "isSigner": false + }, + { + "name": "authority", + "isMut": false, + "isSigner": true + }, + { + "name": "feePayer", + "isMut": true, + "isSigner": true + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "AddMinterAuthorityArgs" + } + } + ] + }, + { + "name": "removeMinterAuthority", + "accounts": [ + { + "name": "minter", + "isMut": true, + "isSigner": false + }, + { + "name": "feePayer", + "isMut": true, + "isSigner": true + }, + { + "name": "authority", + "isMut": false, + "isSigner": true + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "RemoveMinterAuthorityArgs" + } + } + ] + }, { "name": "mintMinterWns", "accounts": [ @@ -222,9 +283,245 @@ export type TokengatorMinter = { } } ] + }, + { + "name": "updateMemberMetdata", + "accounts": [ + { + "name": "minter", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "UpdateMemberMetadataArgs" + } + } + ] + }, + { + "name": "updateMemberMetadataWns", + "accounts": [ + { + "name": "minter", + "isMut": true, + "isSigner": false + }, + { + "name": "group", + "isMut": false, + "isSigner": false + }, + { + "name": "member", + "isMut": false, + "isSigner": false + }, + { + "name": "mint", + "isMut": true, + "isSigner": false + }, + { + "name": "feePayer", + "isMut": true, + "isSigner": true + }, + { + "name": "wnsProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "UpdateMemberMetadataWNSArgs" + } + } + ] + }, + { + "name": "removeMinter", + "accounts": [ + { + "name": "minter", + "isMut": true, + "isSigner": false + }, + { + "name": "mint", + "isMut": true, + "isSigner": false + }, + { + "name": "feePayer", + "isMut": true, + "isSigner": true + }, + { + "name": "authority", + "isMut": false, + "isSigner": true + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "associatedTokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "createActivity", + "accounts": [ + { + "name": "activity", + "isMut": true, + "isSigner": false + }, + { + "name": "minter", + "isMut": false, + "isSigner": false + }, + { + "name": "group", + "isMut": false, + "isSigner": false + }, + { + "name": "member", + "isMut": false, + "isSigner": false + }, + { + "name": "mint", + "isMut": false, + "isSigner": false + }, + { + "name": "feePayer", + "isMut": true, + "isSigner": true + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "CreateActivityArgs" + } + } + ] + }, + { + "name": "appendActivityEntry", + "accounts": [ + { + "name": "activity", + "isMut": true, + "isSigner": false + }, + { + "name": "feePayer", + "isMut": true, + "isSigner": true + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "AppendActivityEntryArgs" + } + } + ] } ], "accounts": [ + { + "name": "activity", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "label", + "type": "string" + }, + { + "name": "startDate", + "type": "i64" + }, + { + "name": "endDate", + "type": "i64" + }, + { + "name": "feePayer", + "type": "publicKey" + }, + { + "name": "minter", + "type": "publicKey" + }, + { + "name": "member", + "type": "publicKey" + }, + { + "name": "mint", + "type": "publicKey" + }, + { + "name": "entries", + "type": { + "vec": { + "defined": "Entry" + } + } + } + ] + } + }, { "name": "group", "type": { @@ -262,6 +559,10 @@ export type TokengatorMinter = { "name": "communityId", "type": "publicKey" }, + { + "name": "group", + "type": "publicKey" + }, { "name": "name", "type": "string" @@ -302,7 +603,61 @@ export type TokengatorMinter = { ], "types": [ { - "name": "AddPresetAuthorityArgs", + "name": "AppendActivityEntryArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "timestamp", + "type": { + "option": "i64" + } + }, + { + "name": "message", + "type": "string" + }, + { + "name": "url", + "type": { + "option": "string" + } + }, + { + "name": "points", + "type": { + "option": "u8" + } + } + ] + } + }, + { + "name": "CreateActivityArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "label", + "type": "string" + }, + { + "name": "startDate", + "type": { + "option": "i64" + } + }, + { + "name": "endDate", + "type": { + "option": "i64" + } + } + ] + } + }, + { + "name": "AddMinterAuthorityArgs", "type": { "kind": "struct", "fields": [ @@ -314,7 +669,19 @@ export type TokengatorMinter = { } }, { - "name": "CreateMinterWNSArgs", + "name": "RemoveMinterAuthorityArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "authorityToRemove", + "type": "publicKey" + } + ] + } + }, + { + "name": "CreateMinterArgs", "type": { "kind": "struct", "fields": [ @@ -353,26 +720,50 @@ export type TokengatorMinter = { } }, { - "name": "interestConfig", + "name": "interestConfig", + "type": { + "option": { + "defined": "MinterInterestConfig" + } + } + }, + { + "name": "transferFeeConfig", + "type": { + "option": { + "defined": "MinterTransferFeeConfig" + } + } + } + ] + } + }, + { + "name": "UpdateMemberMetadataArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "label", + "type": "string" + }, + { + "name": "startDate", "type": { - "option": { - "defined": "MinterInterestConfig" - } + "option": "i64" } }, { - "name": "transferFeeConfig", + "name": "endDate", "type": { - "option": { - "defined": "MinterTransferFeeConfig" - } + "option": "i64" } } ] } }, { - "name": "CreateMinterArgs", + "name": "CreateMinterWNSArgs", "type": { "kind": "struct", "fields": [ @@ -445,18 +836,61 @@ export type TokengatorMinter = { { "name": "uri", "type": "string" + }, + { + "name": "metadata", + "type": { + "option": { + "vec": { + "array": [ + "string", + 2 + ] + } + } + } } ] } }, { - "name": "RemovePresetAuthorityArgs", + "name": "UpdateMemberMetadataWNSArgs", "type": { "kind": "struct", "fields": [ { - "name": "authorityToRemove", - "type": "publicKey" + "name": "field", + "type": "string" + }, + { + "name": "newValue", + "type": "string" + } + ] + } + }, + { + "name": "Entry", + "type": { + "kind": "struct", + "fields": [ + { + "name": "timestamp", + "type": "i64" + }, + { + "name": "message", + "type": "string" + }, + { + "name": "url", + "type": { + "option": "string" + } + }, + { + "name": "points", + "type": "u8" } ] } @@ -834,22 +1268,238 @@ export const IDL: TokengatorMinter = { "isSigner": true }, { - "name": "rent", + "name": "rent", + "isMut": false, + "isSigner": false + }, + { + "name": "wnsProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "associatedTokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "CreateMinterWNSArgs" + } + } + ] + }, + { + "name": "addMinterAuthority", + "accounts": [ + { + "name": "minter", + "isMut": true, + "isSigner": false + }, + { + "name": "authority", + "isMut": false, + "isSigner": true + }, + { + "name": "feePayer", + "isMut": true, + "isSigner": true + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "AddMinterAuthorityArgs" + } + } + ] + }, + { + "name": "removeMinterAuthority", + "accounts": [ + { + "name": "minter", + "isMut": true, + "isSigner": false + }, + { + "name": "feePayer", + "isMut": true, + "isSigner": true + }, + { + "name": "authority", + "isMut": false, + "isSigner": true + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "RemoveMinterAuthorityArgs" + } + } + ] + }, + { + "name": "mintMinterWns", + "accounts": [ + { + "name": "manager", + "isMut": false, + "isSigner": false, + "docs": [ + "WNS ACCOUNTS" + ] + }, + { + "name": "group", + "isMut": true, + "isSigner": false + }, + { + "name": "member", + "isMut": true, + "isSigner": false + }, + { + "name": "minter", + "isMut": true, + "isSigner": false, + "docs": [ + "" + ] + }, + { + "name": "mint", + "isMut": true, + "isSigner": true + }, + { + "name": "authorityTokenAccount", + "isMut": true, + "isSigner": false + }, + { + "name": "feePayer", + "isMut": true, + "isSigner": true + }, + { + "name": "authority", + "isMut": true, + "isSigner": true + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "wnsProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "associatedTokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "MintMinterWNSArgs" + } + } + ] + }, + { + "name": "updateMemberMetdata", + "accounts": [ + { + "name": "minter", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "UpdateMemberMetadataArgs" + } + } + ] + }, + { + "name": "updateMemberMetadataWns", + "accounts": [ + { + "name": "minter", + "isMut": true, + "isSigner": false + }, + { + "name": "group", + "isMut": false, + "isSigner": false + }, + { + "name": "member", "isMut": false, "isSigner": false }, { - "name": "wnsProgram", - "isMut": false, + "name": "mint", + "isMut": true, "isSigner": false }, { - "name": "tokenProgram", + "name": "feePayer", + "isMut": true, + "isSigner": true + }, + { + "name": "wnsProgram", "isMut": false, "isSigner": false }, { - "name": "associatedTokenProgram", + "name": "tokenProgram", "isMut": false, "isSigner": false }, @@ -863,82 +1513,115 @@ export const IDL: TokengatorMinter = { { "name": "args", "type": { - "defined": "CreateMinterWNSArgs" + "defined": "UpdateMemberMetadataWNSArgs" } } ] }, { - "name": "mintMinterWns", + "name": "removeMinter", "accounts": [ { - "name": "manager", - "isMut": false, - "isSigner": false, - "docs": [ - "WNS ACCOUNTS" - ] - }, - { - "name": "group", + "name": "minter", "isMut": true, "isSigner": false }, { - "name": "member", + "name": "mint", "isMut": true, "isSigner": false }, { - "name": "minter", + "name": "feePayer", "isMut": true, - "isSigner": false, - "docs": [ - "" - ] + "isSigner": true }, { - "name": "mint", - "isMut": true, + "name": "authority", + "isMut": false, "isSigner": true }, { - "name": "authorityTokenAccount", - "isMut": true, + "name": "tokenProgram", + "isMut": false, "isSigner": false }, { - "name": "feePayer", - "isMut": true, - "isSigner": true + "name": "associatedTokenProgram", + "isMut": false, + "isSigner": false }, { - "name": "authority", + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "createActivity", + "accounts": [ + { + "name": "activity", "isMut": true, - "isSigner": true + "isSigner": false }, { - "name": "tokenProgram", + "name": "minter", "isMut": false, "isSigner": false }, { - "name": "wnsProgram", + "name": "group", "isMut": false, "isSigner": false }, { - "name": "associatedTokenProgram", + "name": "member", + "isMut": false, + "isSigner": false + }, + { + "name": "mint", "isMut": false, "isSigner": false }, + { + "name": "feePayer", + "isMut": true, + "isSigner": true + }, { "name": "systemProgram", "isMut": false, "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "CreateActivityArgs" + } + } + ] + }, + { + "name": "appendActivityEntry", + "accounts": [ + { + "name": "activity", + "isMut": true, + "isSigner": false }, { - "name": "rent", + "name": "feePayer", + "isMut": true, + "isSigner": true + }, + { + "name": "systemProgram", "isMut": false, "isSigner": false } @@ -947,13 +1630,61 @@ export const IDL: TokengatorMinter = { { "name": "args", "type": { - "defined": "MintMinterWNSArgs" + "defined": "AppendActivityEntryArgs" } } ] } ], "accounts": [ + { + "name": "activity", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "label", + "type": "string" + }, + { + "name": "startDate", + "type": "i64" + }, + { + "name": "endDate", + "type": "i64" + }, + { + "name": "feePayer", + "type": "publicKey" + }, + { + "name": "minter", + "type": "publicKey" + }, + { + "name": "member", + "type": "publicKey" + }, + { + "name": "mint", + "type": "publicKey" + }, + { + "name": "entries", + "type": { + "vec": { + "defined": "Entry" + } + } + } + ] + } + }, { "name": "group", "type": { @@ -991,6 +1722,10 @@ export const IDL: TokengatorMinter = { "name": "communityId", "type": "publicKey" }, + { + "name": "group", + "type": "publicKey" + }, { "name": "name", "type": "string" @@ -1031,7 +1766,61 @@ export const IDL: TokengatorMinter = { ], "types": [ { - "name": "AddPresetAuthorityArgs", + "name": "AppendActivityEntryArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "timestamp", + "type": { + "option": "i64" + } + }, + { + "name": "message", + "type": "string" + }, + { + "name": "url", + "type": { + "option": "string" + } + }, + { + "name": "points", + "type": { + "option": "u8" + } + } + ] + } + }, + { + "name": "CreateActivityArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "label", + "type": "string" + }, + { + "name": "startDate", + "type": { + "option": "i64" + } + }, + { + "name": "endDate", + "type": { + "option": "i64" + } + } + ] + } + }, + { + "name": "AddMinterAuthorityArgs", "type": { "kind": "struct", "fields": [ @@ -1043,7 +1832,19 @@ export const IDL: TokengatorMinter = { } }, { - "name": "CreateMinterWNSArgs", + "name": "RemoveMinterAuthorityArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "authorityToRemove", + "type": "publicKey" + } + ] + } + }, + { + "name": "CreateMinterArgs", "type": { "kind": "struct", "fields": [ @@ -1101,7 +1902,31 @@ export const IDL: TokengatorMinter = { } }, { - "name": "CreateMinterArgs", + "name": "UpdateMemberMetadataArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "label", + "type": "string" + }, + { + "name": "startDate", + "type": { + "option": "i64" + } + }, + { + "name": "endDate", + "type": { + "option": "i64" + } + } + ] + } + }, + { + "name": "CreateMinterWNSArgs", "type": { "kind": "struct", "fields": [ @@ -1174,18 +1999,61 @@ export const IDL: TokengatorMinter = { { "name": "uri", "type": "string" + }, + { + "name": "metadata", + "type": { + "option": { + "vec": { + "array": [ + "string", + 2 + ] + } + } + } + } + ] + } + }, + { + "name": "UpdateMemberMetadataWNSArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "field", + "type": "string" + }, + { + "name": "newValue", + "type": "string" } ] } }, { - "name": "RemovePresetAuthorityArgs", + "name": "Entry", "type": { "kind": "struct", "fields": [ { - "name": "authorityToRemove", - "type": "publicKey" + "name": "timestamp", + "type": "i64" + }, + { + "name": "message", + "type": "string" + }, + { + "name": "url", + "type": { + "option": "string" + } + }, + { + "name": "points", + "type": "u8" } ] } diff --git a/libs/api/solana/util/src/lib/tokengator-minter.ts b/libs/api/solana/util/src/lib/tokengator-minter.ts index 97e573c..32bd7b0 100644 --- a/libs/api/solana/util/src/lib/tokengator-minter.ts +++ b/libs/api/solana/util/src/lib/tokengator-minter.ts @@ -8,6 +8,7 @@ import { export const PREFIX = encodeToBuffer('tokengator_minter') export const MINTER = encodeToBuffer('minter') +export const ACTIVITY = encodeToBuffer('activity') export enum IdentityProvider { Discord = 'discord', @@ -67,6 +68,10 @@ function encodeToBuffer(input: string) { return new TextEncoder().encode(input) } +export function getActivityPda({ programId, mint, label }: { label: string; mint: PublicKey; programId: PublicKey }) { + return PublicKey.findProgramAddressSync([PREFIX, ACTIVITY, mint.toBuffer(), encodeToBuffer(label)], programId) +} + export function getMetadataProgram(provider: Provider, programId: PublicKey = WEN_NEW_STANDARD_PROGRAM_ID) { return new Program(WenNewStandardIDL, programId, provider) as unknown as Program }