forked from sendaifun/solana-agent-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate Metaplex DAS API (sendaifun#215)
- Loading branch information
Showing
20 changed files
with
1,219 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { Action } from "../../types/action"; | ||
import { SolanaAgentKit } from "../../agent"; | ||
import { z } from "zod"; | ||
import { get_asset } from "../../tools/metaplex"; | ||
|
||
const getAssetAction: Action = { | ||
name: "GET_ASSET", | ||
similes: [ | ||
"fetch asset", | ||
"retrieve asset", | ||
"get asset details", | ||
"fetch asset details", | ||
], | ||
description: `Fetch asset details using the Metaplex DAS API.`, | ||
examples: [ | ||
[ | ||
{ | ||
input: { | ||
assetId: "Asset ID", | ||
}, | ||
output: { | ||
status: "success", | ||
message: "Asset retrieved successfully", | ||
result: { | ||
// Example asset details | ||
name: "Example Asset", | ||
symbol: "EXA", | ||
uri: "https://example.com/asset.json", | ||
}, | ||
}, | ||
explanation: "Fetch details of an asset using its ID", | ||
}, | ||
], | ||
], | ||
schema: z.object({ | ||
assetId: z.string().min(1, "Asset ID is required"), | ||
}), | ||
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => { | ||
const assetId = input.assetId; | ||
|
||
const result = await get_asset(agent, assetId); | ||
|
||
return { | ||
status: "success", | ||
message: "Asset retrieved successfully", | ||
result, | ||
}; | ||
}, | ||
}; | ||
|
||
export default getAssetAction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import { Action } from "../../types/action"; | ||
import { SolanaAgentKit } from "../../agent"; | ||
import { z } from "zod"; | ||
import { get_assets_by_authority } from "../../tools/metaplex"; | ||
|
||
const getAssetsByAuthorityAction: Action = { | ||
name: "GET_ASSETS_BY_AUTHORITY", | ||
similes: [ | ||
"fetch assets by authority", | ||
"retrieve assets by authority", | ||
"get assets by authority address", | ||
"fetch authority assets", | ||
], | ||
description: `Fetch a list of assets owned by a specific address using the Metaplex DAS API.`, | ||
examples: [ | ||
[ | ||
{ | ||
input: { | ||
authority: "mRdta4rc2RtsxEUDYuvKLamMZAdW6qHcwuq866Skxxv", | ||
limit: 10, | ||
}, | ||
output: { | ||
status: "success", | ||
message: "Assets retrieved successfully", | ||
result: { | ||
total: 2, | ||
limit: 10, | ||
items: [ | ||
{ | ||
interface: "V1_NFT", | ||
id: "ExampleAssetId1", | ||
content: { | ||
json_uri: "https://example.com/asset1.json", | ||
metadata: { | ||
name: "Example Asset 1", | ||
symbol: "EXA1", | ||
}, | ||
}, | ||
authorities: [], | ||
compression: {}, | ||
grouping: [], | ||
royalty: {}, | ||
creators: [], | ||
ownership: {}, | ||
supply: {}, | ||
mutable: true, | ||
burnt: false, | ||
}, | ||
{ | ||
interface: "V1_NFT", | ||
id: "ExampleAssetId2", | ||
content: { | ||
json_uri: "https://example.com/asset2.json", | ||
metadata: { | ||
name: "Example Asset 2", | ||
symbol: "EXA2", | ||
}, | ||
}, | ||
authorities: [], | ||
compression: {}, | ||
grouping: [], | ||
royalty: {}, | ||
creators: [], | ||
ownership: {}, | ||
supply: {}, | ||
mutable: true, | ||
burnt: false, | ||
}, | ||
], | ||
}, | ||
}, | ||
explanation: "Fetch a list of assets owned by a specific address", | ||
}, | ||
], | ||
], | ||
schema: z.object({ | ||
authority: z.string().min(1, "Authority address is required"), | ||
sortBy: z | ||
.object({ | ||
sortBy: z.enum(["created", "updated", "recentAction", "none"]), | ||
sortDirection: z.enum(["asc", "desc"]), | ||
}) | ||
.optional(), | ||
limit: z.number().optional(), | ||
page: z.number().optional(), | ||
before: z.string().optional(), | ||
after: z.string().optional(), | ||
}), | ||
handler: async ( | ||
agent: SolanaAgentKit, | ||
input: z.infer<typeof getAssetsByAuthorityAction.schema>, | ||
) => { | ||
const result = await get_assets_by_authority(agent, input); | ||
|
||
return { | ||
status: "success", | ||
message: "Assets retrieved successfully", | ||
result, | ||
}; | ||
}, | ||
}; | ||
|
||
export default getAssetsByAuthorityAction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import { Action } from "../../types/action"; | ||
import { SolanaAgentKit } from "../../agent"; | ||
import { z } from "zod"; | ||
import { get_assets_by_creator } from "../../tools/metaplex"; | ||
|
||
const getAssetsByCreatorAction: Action = { | ||
name: "GET_ASSETS_BY_CREATOR", | ||
similes: [ | ||
"fetch assets by creator", | ||
"retrieve assets by creator", | ||
"get assets by creator address", | ||
"fetch creator assets", | ||
], | ||
description: `Fetch a list of assets created by a specific address using the Metaplex DAS API.`, | ||
examples: [ | ||
[ | ||
{ | ||
input: { | ||
creator: "D3XrkNZz6wx6cofot7Zohsf2KSsu2ArngNk8VqU9cTY3", | ||
onlyVerified: true, | ||
limit: 10, | ||
}, | ||
output: { | ||
status: "success", | ||
message: "Assets retrieved successfully", | ||
result: { | ||
total: 2, | ||
limit: 10, | ||
items: [ | ||
{ | ||
interface: "V1_NFT", | ||
id: "ExampleAssetId1", | ||
content: { | ||
json_uri: "https://example.com/asset1.json", | ||
metadata: { | ||
name: "Example Asset 1", | ||
symbol: "EXA1", | ||
}, | ||
}, | ||
authorities: [], | ||
compression: {}, | ||
grouping: [], | ||
royalty: {}, | ||
creators: [], | ||
ownership: {}, | ||
supply: {}, | ||
mutable: true, | ||
burnt: false, | ||
}, | ||
{ | ||
interface: "V1_NFT", | ||
id: "ExampleAssetId2", | ||
content: { | ||
json_uri: "https://example.com/asset2.json", | ||
metadata: { | ||
name: "Example Asset 2", | ||
symbol: "EXA2", | ||
}, | ||
}, | ||
authorities: [], | ||
compression: {}, | ||
grouping: [], | ||
royalty: {}, | ||
creators: [], | ||
ownership: {}, | ||
supply: {}, | ||
mutable: true, | ||
burnt: false, | ||
}, | ||
], | ||
}, | ||
}, | ||
explanation: "Fetch a list of assets created by a specific address", | ||
}, | ||
], | ||
], | ||
schema: z.object({ | ||
creator: z.string().min(1, "Creator address is required"), | ||
onlyVerified: z.boolean(), | ||
sortBy: z | ||
.object({ | ||
sortBy: z.enum(["created", "updated", "recentAction", "none"]), | ||
sortDirection: z.enum(["asc", "desc"]), | ||
}) | ||
.optional(), | ||
limit: z.number().optional(), | ||
page: z.number().optional(), | ||
before: z.string().optional(), | ||
after: z.string().optional(), | ||
}), | ||
handler: async ( | ||
agent: SolanaAgentKit, | ||
input: z.infer<typeof getAssetsByCreatorAction.schema>, | ||
) => { | ||
const result = await get_assets_by_creator(agent, input); | ||
|
||
return { | ||
status: "success", | ||
message: "Assets retrieved successfully", | ||
result, | ||
}; | ||
}, | ||
}; | ||
|
||
export default getAssetsByCreatorAction; |
Oops, something went wrong.