Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

refactor(experimental): graphql: token-2022 extensions: UpdateField #2693

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/rpc-graphql/src/__tests__/__setup__.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2659,6 +2659,20 @@ export const mockTransactionToken2022AllExtensions = {
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
stackHeight: null,
},
{
parsed: {
info: {
metadata: 'FsHcsGiY43QmZc6yTgwYC1DA5U3ZgycXxn3bd2oBjrEZ',
updateAuthority: 'FsHcsGiY43QmZc6yTgwYC1DA5U3ZgycXxn3bd2oBjrEZ',
field: 'newField',
value: 'newValue',
},
type: 'updateTokenMetadataField',
},
program: 'spl-token',
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
stackHeight: null,
},
// TODO (more) ...
],
recentBlockhash: '6vRS7MoToVccMqfQecdVC6UbmARaT5mha91zhreqnce9',
Expand Down
47 changes: 47 additions & 0 deletions packages/rpc-graphql/src/__tests__/transaction-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3607,6 +3607,53 @@ describe('transaction', () => {
},
});
});

it('update-token-metadata-field', async () => {
expect.assertions(1);
const source = /* GraphQL */ `
query testQuery($signature: Signature!) {
transaction(signature: $signature) {
message {
instructions {
programId
... on SplTokenMetadataUpdateField {
field
metadata {
address
}
updateAuthority {
address
}
value
}
}
}
}
}
`;
const result = await rpcGraphQL.query(source, { signature });
expect(result).toMatchObject({
data: {
transaction: {
message: {
instructions: expect.arrayContaining([
{
field: expect.any(String),
metadata: {
address: expect.any(String),
},
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
updateAuthority: {
address: expect.any(String),
},
value: expect.any(String),
},
]),
},
},
},
});
});
});
});
});
7 changes: 7 additions & 0 deletions packages/rpc-graphql/src/resolvers/instruction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,10 @@ export const instructionResolvers = {
mintAuthority: resolveAccount('mintAuthority'),
updateAuthority: resolveAccount('updateAuthority'),
},
SplTokenMetadataUpdateField: {
metadata: resolveAccount('metadata'),
updateAuthority: resolveAccount('updateAuthority'),
},
SplTokenMintToCheckedInstruction: {
account: resolveAccount('account'),
authority: resolveAccount('authority'),
Expand Down Expand Up @@ -925,6 +929,9 @@ export const instructionResolvers = {
if (jsonParsedConfigs.instructionType === 'initializeTokenMetadata') {
return 'SplTokenMetadataInitialize';
}
if (jsonParsedConfigs.instructionType === 'updateTokenMetadataField') {
return 'SplTokenMetadataUpdateField';
}
}
if (jsonParsedConfigs.programName === 'stake') {
if (jsonParsedConfigs.instructionType === 'initialize') {
Expand Down
11 changes: 11 additions & 0 deletions packages/rpc-graphql/src/schema/instruction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,17 @@ export const instructionTypeDefs = /* GraphQL */ `
uri: String
}

"""
Spl Token Metadata: UpdateField instruction
"""
type SplTokenMetadataUpdateField implements TransactionInstruction {
programId: Address
field: String
metadata: Account
updateAuthority: Account
value: String
}

type Lockup {
custodian: Account
epoch: Epoch
Expand Down