Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,98 @@ export async function createWalletAccessToken(props: {
],
type: "eoa:create",
},
{
metadataPatterns: [
{
key: "projectId",
rule: {
pattern: props.project.id,
},
},
{
key: "teamId",
rule: {
pattern: props.project.teamId,
},
},
{
key: "type",
rule: {
pattern: "server-wallet",
},
},
],
type: "solana:read",
},
{
requiredMetadataPatterns: [
{
key: "projectId",
rule: {
pattern: props.project.id,
},
},
{
key: "teamId",
rule: {
pattern: props.project.teamId,
},
},
{
key: "type",
rule: {
pattern: "server-wallet",
},
},
],
type: "solana:create",
},
{
metadataPatterns: [
{
key: "projectId",
rule: {
pattern: props.project.id,
},
},
{
key: "teamId",
rule: {
pattern: props.project.teamId,
},
},
{
key: "type",
rule: {
pattern: "server-wallet",
},
},
],
type: "solana:signTransaction",
},
{
metadataPatterns: [
{
key: "projectId",
rule: {
pattern: props.project.id,
},
},
{
key: "teamId",
rule: {
pattern: props.project.teamId,
},
},
{
key: "type",
rule: {
pattern: "server-wallet",
},
},
],
type: "solana:signMessage",
},
Comment on lines +563 to +654
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Approve Solana wallet policies with refactor recommendation.

The Solana policy additions correctly mirror the existing EVM policy structure and will enable Solana wallet operations. However, the identical metadataPatterns structure across all policies creates significant duplication.

Consider extracting a helper function to generate policy objects:

function createWalletPolicy(
  type: string,
  projectId: string,
  teamId: string,
  additionalOptions?: Record<string, unknown>
) {
  const metadataPatterns = [
    { key: "projectId", rule: { pattern: projectId } },
    { key: "teamId", rule: { pattern: teamId } },
    { key: "type", rule: { pattern: "server-wallet" } },
  ];

  return {
    ...(type.includes(":create") 
      ? { requiredMetadataPatterns: metadataPatterns }
      : { metadataPatterns }),
    type,
    ...additionalOptions,
  };
}

Then replace the policy blocks:

policies: [
  // EVM policies
  createWalletPolicy("eoa:read", props.project.id, props.project.teamId),
  createWalletPolicy("eoa:create", props.project.id, props.project.teamId),
  createWalletPolicy("eoa:signMessage", props.project.id, props.project.teamId),
  createWalletPolicy("eoa:signTransaction", props.project.id, props.project.teamId, {
    payloadPatterns: {}
  }),
  // ... other EVM policies
  // Solana policies
  createWalletPolicy("solana:read", props.project.id, props.project.teamId),
  createWalletPolicy("solana:create", props.project.id, props.project.teamId),
  createWalletPolicy("solana:signTransaction", props.project.id, props.project.teamId),
  createWalletPolicy("solana:signMessage", props.project.id, props.project.teamId),
]

This would also address the pre-existing duplicate eoa:read and eoa:create policies at lines 351-396 and 517-562.

🤖 Prompt for AI Agents
In
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/transactions/lib/vault.client.ts
around lines 563-654, the four Solana policy objects repeat identical
metadataPatterns causing duplication; extract a small helper (e.g.,
createWalletPolicy) that accepts type, projectId, teamId and optional extra
options, builds the common metadataPatterns and returns either metadataPatterns
or requiredMetadataPatterns for create types, then replace the repeated Solana
policy blocks with calls to that helper (and likewise replace the duplicated EVM
eoa:read/eoa:create blocks at lines ~351-396 and ~517-562) to deduplicate and
keep payload-specific options passed through the helper.

],
},
},
Expand Down Expand Up @@ -633,6 +725,52 @@ async function createManagementAccessToken(props: {
],
type: "eoa:create",
},
{
metadataPatterns: [
{
key: "projectId",
rule: {
pattern: props.project.id,
},
},
{
key: "teamId",
rule: {
pattern: props.project.teamId,
},
},
{
key: "type",
rule: {
pattern: "server-wallet",
},
},
],
type: "solana:read",
},
{
requiredMetadataPatterns: [
{
key: "projectId",
rule: {
pattern: props.project.id,
},
},
{
key: "teamId",
rule: {
pattern: props.project.teamId,
},
},
{
key: "type",
rule: {
pattern: "server-wallet",
},
},
],
type: "solana:create",
},
Comment on lines +728 to +773
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Approve Solana management policies.

The Solana management token policies are correctly limited to read and create operations (no signing), which matches the EVM policy structure. This is the appropriate permission model for management tokens.

The same helper function refactor suggested for lines 563-654 would reduce duplication here as well. Both createWalletAccessToken and createManagementAccessToken would benefit from the extracted policy generation helper.

🤖 Prompt for AI Agents
In
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/transactions/lib/vault.client.ts
around lines 728 to 773, the Solana management token policy blocks are correct
but duplicate policy-building logic; extract a small helper (e.g.,
buildSolanaPolicies(project, teamId, types[] or mode)) that returns the array of
policy objects (metadataPatterns/requiredMetadataPatterns and type) and replace
the inline policy arrays in createWalletAccessToken and
createManagementAccessToken with calls to this helper to remove duplication and
centralize policy construction.

{
metadataPatterns: [
{
Expand Down
Loading