Skip to content

Commit

Permalink
fix formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
bryan-eastwood3 committed Dec 6, 2024
1 parent 614b5f6 commit e1b3f94
Show file tree
Hide file tree
Showing 9 changed files with 370 additions and 424 deletions.
1 change: 1 addition & 0 deletions biome.json
60 changes: 30 additions & 30 deletions typescript/biome.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": false,
"clientKind": "git",
"useIgnoreFile": false
},
"files": {
"ignoreUnknown": false,
"ignore": ["dist/**/*"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 4,
"lineWidth": 120
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"javascript": {
"formatter": {
"quoteStyle": "double"
}
}
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": false,
"clientKind": "git",
"useIgnoreFile": false
},
"files": {
"ignoreUnknown": false,
"ignore": ["dist/**/*"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 4,
"lineWidth": 120
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"javascript": {
"formatter": {
"quoteStyle": "double"
}
}
}
62 changes: 31 additions & 31 deletions typescript/packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
{
"name": "@goat-sdk/core",
"version": "0.3.10",
"sideEffects": false,
"files": ["dist/**/*", "README.md", "package.json"],
"scripts": {
"build": "tsup",
"clean": "rm -rf dist",
"test": "vitest run --passWithNoTests"
},
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"dependencies": {
"@metaplex-foundation/mpl-bubblegum": "^4.2.1",
"@metaplex-foundation/umi-bundle-defaults": "^0.9.2",
"@metaplex-foundation/umi-web3js-adapters": "^0.9.2",
"@solana/web3.js": "1.95.8",
"abitype": "^1.0.6",
"viem": "^2.21.49",
"zod": "^3.23.8"
},
"homepage": "https://ohmygoat.dev",
"repository": {
"type": "git",
"url": "git+https://github.com/goat-sdk/goat.git"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/goat-sdk/goat/issues"
},
"keywords": ["ai", "agents", "web3"]
"name": "@goat-sdk/core",
"version": "0.3.10",
"sideEffects": false,
"files": ["dist/**/*", "README.md", "package.json"],
"scripts": {
"build": "tsup",
"clean": "rm -rf dist",
"test": "vitest run --passWithNoTests"
},
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"dependencies": {
"@metaplex-foundation/mpl-bubblegum": "^4.2.1",
"@metaplex-foundation/umi-bundle-defaults": "^0.9.2",
"@metaplex-foundation/umi-web3js-adapters": "^0.9.2",
"@solana/web3.js": "1.95.8",
"abitype": "^1.0.6",
"viem": "^2.21.49",
"zod": "^3.23.8"
},
"homepage": "https://ohmygoat.dev",
"repository": {
"type": "git",
"url": "git+https://github.com/goat-sdk/goat.git"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/goat-sdk/goat/issues"
},
"keywords": ["ai", "agents", "web3"]
}
98 changes: 49 additions & 49 deletions typescript/packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,59 @@ import type { Plugin } from "./plugins/plugins";
import { sendETH } from "./plugins/send-eth";
import { sendSOL } from "./plugins/solana/send-sol";
import {
type DeferredTool,
type GetDeferredToolsParams,
type GetToolsParams,
type Tool,
getDeferredTools,
getTools,
type DeferredTool,
type GetDeferredToolsParams,
type GetToolsParams,
type Tool,
getDeferredTools,
getTools,
} from "./tools";
import { addParametersToDescription, parametersToJsonExample } from "./utils";
import type {
Balance,
Chain,
ChainForWalletClient,
EVMReadRequest,
EVMSmartWalletClient,
EVMTransaction,
EVMTypedData,
EVMWalletClient,
Signature,
SolanaReadRequest,
SolanaTransaction,
SolanaWalletClient,
WalletClient,
isEVMSmartWalletClient,
isEVMWalletClient,
isSolanaWalletClient,
Balance,
Chain,
ChainForWalletClient,
EVMReadRequest,
EVMSmartWalletClient,
EVMTransaction,
EVMTypedData,
EVMWalletClient,
Signature,
SolanaReadRequest,
SolanaTransaction,
SolanaWalletClient,
WalletClient,
isEVMSmartWalletClient,
isEVMWalletClient,
isSolanaWalletClient,
} from "./wallets";

export {
getTools,
getDeferredTools,
sendETH,
sendSOL,
addParametersToDescription,
parametersToJsonExample,
type Tool,
type DeferredTool,
type GetToolsParams,
type GetDeferredToolsParams,
type Plugin,
type WalletClient,
type EVMTransaction,
type EVMReadRequest,
type EVMWalletClient,
type EVMSmartWalletClient,
type SolanaTransaction,
type SolanaReadRequest,
type SolanaWalletClient,
type Signature,
type Balance,
type EVMTypedData,
type isEVMWalletClient,
type isEVMSmartWalletClient,
type isSolanaWalletClient,
type Chain,
type ChainForWalletClient,
getTools,
getDeferredTools,
sendETH,
sendSOL,
addParametersToDescription,
parametersToJsonExample,
type Tool,
type DeferredTool,
type GetToolsParams,
type GetDeferredToolsParams,
type Plugin,
type WalletClient,
type EVMTransaction,
type EVMReadRequest,
type EVMWalletClient,
type EVMSmartWalletClient,
type SolanaTransaction,
type SolanaReadRequest,
type SolanaWalletClient,
type Signature,
type Balance,
type EVMTypedData,
type isEVMWalletClient,
type isEVMSmartWalletClient,
type isSolanaWalletClient,
type Chain,
type ChainForWalletClient,
};
79 changes: 34 additions & 45 deletions typescript/packages/core/src/plugins/solana/nfts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,50 @@ import { PublicKey } from "@solana/web3.js";
import type { SolanaWalletClient } from "../../wallets";
import type { Plugin } from "../plugins";
import { z } from "zod";
import {
mplBubblegum,
getAssetWithProof,
transfer,
} from "@metaplex-foundation/mpl-bubblegum";
import { mplBubblegum, getAssetWithProof, transfer } from "@metaplex-foundation/mpl-bubblegum";
import { createUmi } from "@metaplex-foundation/umi-bundle-defaults";
import {
fromWeb3JsPublicKey,
toWeb3JsInstruction,
} from "@metaplex-foundation/umi-web3js-adapters";
import { fromWeb3JsPublicKey, toWeb3JsInstruction } from "@metaplex-foundation/umi-web3js-adapters";

export function nfts(): Plugin<SolanaWalletClient> {
return {
name: "nft_actions",
supportsSmartWallets: () => true,
supportsChain: (chain) => chain.type === "solana",
getTools: async () => {
return [
{
name: "transfer_nft",
description:
"This {{tool}} sends an NFT from your wallet to an address on a Solana chain.",
parameters: transferNFTParametersSchema,
method: transferNFTMethod,
},
];
},
};
return {
name: "nft_actions",
supportsSmartWallets: () => true,
supportsChain: (chain) => chain.type === "solana",
getTools: async () => {
return [
{
name: "transfer_nft",
description: "This {{tool}} sends an NFT from your wallet to an address on a Solana chain.",
parameters: transferNFTParametersSchema,
method: transferNFTMethod,
},
];
},
};
}

const transferNFTParametersSchema = z.object({
recipientAddress: z.string().describe("The address to send the NFT to"),
assetId: z.string().describe("The asset ID of the NFT to send"),
recipientAddress: z.string().describe("The address to send the NFT to"),
assetId: z.string().describe("The asset ID of the NFT to send"),
});

async function transferNFTMethod(
walletClient: SolanaWalletClient,
parameters: z.infer<typeof transferNFTParametersSchema>,
walletClient: SolanaWalletClient,
parameters: z.infer<typeof transferNFTParametersSchema>,
): Promise<string> {
const { recipientAddress, assetId } = parameters;
const umi = createUmi(walletClient.connection);
umi.use(mplBubblegum());
const assetWithProof = await getAssetWithProof(
umi,
fromWeb3JsPublicKey(new PublicKey(assetId)),
);
const instructions = transfer(umi, {
...assetWithProof,
leafOwner: fromWeb3JsPublicKey(new PublicKey(walletClient.getAddress())),
newLeafOwner: fromWeb3JsPublicKey(new PublicKey(recipientAddress)),
}).getInstructions();
const { recipientAddress, assetId } = parameters;
const umi = createUmi(walletClient.connection);
umi.use(mplBubblegum());
const assetWithProof = await getAssetWithProof(umi, fromWeb3JsPublicKey(new PublicKey(assetId)));
const instructions = transfer(umi, {
...assetWithProof,
leafOwner: fromWeb3JsPublicKey(new PublicKey(walletClient.getAddress())),
newLeafOwner: fromWeb3JsPublicKey(new PublicKey(recipientAddress)),
}).getInstructions();

const result = await walletClient.sendTransaction({
instructions: instructions.map(toWeb3JsInstruction),
});
const result = await walletClient.sendTransaction({
instructions: instructions.map(toWeb3JsInstruction),
});

return result.hash;
return result.hash;
}
Loading

0 comments on commit e1b3f94

Please sign in to comment.