-
Notifications
You must be signed in to change notification settings - Fork 543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Realm #297
Open
0xNoushad
wants to merge
8
commits into
sendaifun:main
Choose a base branch
from
0xNoushad:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Realm #297
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8ce23f3
everything is done
0xNoushad 09e9840
done
0xNoushad 4755776
Merge branch 'main' into main
0xNoushad 36dc9da
Merge branch 'main' into main
0xNoushad 8323701
file structured
0xNoushad 717381e
actions added / testing reamins
0xNoushad 3cf3ba7
Merge branch 'sendaifun:main' into main
0xNoushad 14ac4e5
transaction complete
0xNoushad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,69 @@ | ||
import { PublicKey } from "@solana/web3.js"; | ||
import { z } from "zod"; | ||
import { SolanaAgentKit } from "../../agent"; | ||
import { Action, VoteConfig } from "../../types"; | ||
|
||
const castVoteAction: Action = { | ||
name: "SPL_CAST_VOTE", | ||
similes: [ | ||
"vote on proposal", | ||
"cast dao vote", | ||
"submit governance vote", | ||
"vote on dao motion", | ||
"participate in dao governance", | ||
"cast ballot on proposal", | ||
], | ||
description: "Cast a vote on an existing proposal in a DAO", | ||
examples: [ | ||
[ | ||
{ | ||
input: { | ||
proposal: "2ZE7Rz...", | ||
tokenOwnerRecord: "8gYZR...", | ||
}, | ||
output: { | ||
status: "success", | ||
voteRecordAddress: "5PmxV...", | ||
message: "Successfully cast vote on proposal", | ||
}, | ||
explanation: "Cast a vote on an existing proposal", | ||
}, | ||
], | ||
], | ||
schema: z.object({ | ||
proposal: z.string().min(1).describe("Address of the proposal to vote on"), | ||
tokenOwnerRecord: z | ||
.string() | ||
.min(1) | ||
.describe("Token owner record address for voting"), | ||
|
||
}), | ||
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => { | ||
try { | ||
|
||
const voteConfig: VoteConfig = { | ||
proposal: new PublicKey(input.proposal), | ||
tokenOwnerRecord: new PublicKey(input.tokenOwnerRecord), | ||
realm: new PublicKey("11111111111111111111111111111111"), | ||
choice: 0, | ||
governingTokenMint: new PublicKey("11111111111111111111111111111111"), | ||
governance: new PublicKey("11111111111111111111111111111111") | ||
}; | ||
|
||
const result = await agent.castVote(voteConfig); | ||
|
||
return { | ||
status: "success", | ||
voteRecordAddress: result.toString(), | ||
message: "Successfully cast vote on proposal", | ||
}; | ||
} catch (error: any) { | ||
return { | ||
status: "error", | ||
message: `Failed to cast vote: ${error.message}`, | ||
}; | ||
} | ||
}, | ||
}; | ||
|
||
export default castVoteAction; |
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,75 @@ | ||
import { PublicKey } from "@solana/web3.js"; | ||
import { z } from "zod"; | ||
import { SolanaAgentKit } from "../../agent"; | ||
import { Action } from "../../types"; | ||
|
||
const createProposalAction: Action = { | ||
name: "SPL_CREATE_PROPOSAL", | ||
similes: [ | ||
"create dao proposal", | ||
"submit governance proposal", | ||
"initiate dao vote", | ||
"propose dao action", | ||
"start governance vote", | ||
"submit dao motion", | ||
], | ||
description: | ||
"Create a new proposal in a DAO realm for community or council voting", | ||
examples: [ | ||
[ | ||
{ | ||
input: { | ||
realm: "7nxQB...", | ||
name: "Treasury Funding Allocation", | ||
description: "Proposal to allocate 1000 tokens to the development team", | ||
governingTokenMint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", | ||
voteType: "single-choice", | ||
}, | ||
output: { | ||
status: "success", | ||
proposalAddress: "2ZE7Rz...", | ||
message: "Successfully created proposal for community voting", | ||
}, | ||
explanation: | ||
"Create a single-choice proposal for community members to vote on", | ||
}, | ||
], | ||
], | ||
schema: z.object({ | ||
realm: z.string().min(1).describe("Address of the DAO realm"), | ||
name: z.string().min(1).describe("Name of the proposal"), | ||
description: z.string().min(1).describe("Description of the proposal"), | ||
governingTokenMint: z | ||
.string() | ||
.min(1) | ||
.describe("Token mint address for voting (community or council)"), | ||
voteType: z | ||
.enum(["single-choice", "multiple-choice"]) | ||
.describe("Type of voting mechanism for the proposal"), | ||
}), | ||
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => { | ||
try { | ||
const result = await agent.createProposal(new PublicKey(input.realm), { | ||
name: input.name, | ||
description: input.description, | ||
governingTokenMint: new PublicKey(input.governingTokenMint), | ||
voteType: input.voteType, | ||
options: ["Approve", "Deny"], | ||
}); | ||
|
||
return { | ||
status: "success", | ||
proposalAddress: result.toString(), | ||
message: `Successfully created proposal: ${input.name}`, | ||
}; | ||
} catch (error: any) { | ||
return { | ||
status: "error", | ||
message: `Failed to create proposal: ${error.message}`, | ||
}; | ||
} | ||
}, | ||
}; | ||
|
||
|
||
export default createProposalAction; |
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,77 @@ | ||
import { PublicKey } from "@solana/web3.js"; | ||
import { z } from "zod"; | ||
import { SolanaAgentKit } from "../../agent"; | ||
import { Action } from "../../types"; | ||
|
||
const createRealmAction: Action = { | ||
name: "SPL_CREATE_REALM", | ||
similes: [ | ||
"create dao realm", | ||
"initialize governance realm", | ||
"setup dao", | ||
"create governance entity", | ||
"establish dao space", | ||
"initialize dao organization", | ||
], | ||
description: | ||
"Create a new DAO realm with specified configuration for on-chain governance", | ||
examples: [ | ||
[ | ||
{ | ||
input: { | ||
name: "My Community DAO", | ||
communityMint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", | ||
minCommunityTokens: 1000, | ||
councilMint: "So11111111111111111111111111111111111111112", | ||
}, | ||
output: { | ||
status: "success", | ||
realmAddress: "7nxQB...", | ||
message: "Successfully created DAO realm", | ||
}, | ||
explanation: | ||
"Create a new DAO realm with community and council tokens for governance", | ||
}, | ||
], | ||
], | ||
schema: z.object({ | ||
name: z.string().min(1).describe("Name of the DAO realm"), | ||
communityMint: z | ||
.string() | ||
.min(1) | ||
.describe("Address of the community token mint"), | ||
minCommunityTokens: z | ||
.number() | ||
.positive() | ||
.describe("Minimum community tokens required to create governance"), | ||
councilMint: z | ||
.string() | ||
.optional() | ||
.describe("Optional address of the council token mint"), | ||
}), | ||
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => { | ||
try { | ||
const result = await agent.createRealm({ | ||
name: input.name, | ||
communityMint: new PublicKey(input.communityMint), | ||
minCommunityTokensToCreateGovernance: input.minCommunityTokens, | ||
councilMint: input.councilMint | ||
? new PublicKey(input.councilMint) | ||
: undefined, | ||
}); | ||
|
||
return { | ||
status: "success", | ||
realmAddress: result.toString(), | ||
message: `Successfully created realm: ${input.name}`, | ||
}; | ||
} catch (error: any) { | ||
return { | ||
status: "error", | ||
message: `Failed to create realm: ${error.message}`, | ||
}; | ||
} | ||
}, | ||
}; | ||
|
||
export default createRealmAction; |
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,71 @@ | ||
import { PublicKey } from "@solana/web3.js"; | ||
import { z } from "zod"; | ||
import { SolanaAgentKit } from "../../agent"; | ||
import { Action } from "../../types"; | ||
|
||
const getTokenOwnerRecordAction: Action = { | ||
name: "SPL_GET_TOKEN_OWNER_RECORD", | ||
similes: [ | ||
"check dao membership status", | ||
"get governance token holdings", | ||
"view dao member record", | ||
"check voting power", | ||
"verify dao participation rights", | ||
"view governance token record", | ||
], | ||
description: "Get token owner record for a member in a DAO realm", | ||
examples: [ | ||
[ | ||
{ | ||
input: { | ||
realm: "7nxQB...", | ||
governingTokenMint: "EPjF...", | ||
governingTokenOwner: "DqYm...", | ||
}, | ||
output: { | ||
status: "success", | ||
tokenOwnerRecord: { | ||
governingTokenOwner: "DqYm...", | ||
tokenBalance: 5000, | ||
// other member data | ||
}, | ||
message: "Successfully retrieved token owner record", | ||
}, | ||
explanation: "Retrieve a member's voting power and participation record", | ||
}, | ||
], | ||
], | ||
schema: z.object({ | ||
realm: z.string().min(1).describe("Address of the DAO realm"), | ||
governingTokenMint: z | ||
.string() | ||
.min(1) | ||
.describe("Token mint address for voting (community or council)"), | ||
governingTokenOwner: z | ||
.string() | ||
.min(1) | ||
.describe("Address of the token owner/member"), | ||
}), | ||
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => { | ||
try { | ||
const result = await agent.getTokenOwnerRecord( | ||
new PublicKey(input.realm), | ||
new PublicKey(input.governingTokenMint), | ||
new PublicKey(input.governingTokenOwner) | ||
); | ||
|
||
return { | ||
status: "success", | ||
tokenOwnerRecord: result, | ||
message: "Successfully retrieved token owner record", | ||
}; | ||
} catch (error: any) { | ||
return { | ||
status: "error", | ||
message: `Failed to get token owner record: ${error.message}`, | ||
}; | ||
} | ||
}, | ||
}; | ||
|
||
export default getTokenOwnerRecordAction; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove unnecessary white spaces/lines from any files that may have them