UNPKG

@coinbase/agentkit

Version:

Coinbase AgentKit core primitives

131 lines (130 loc) 5.95 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.clankerActionProvider = exports.ClankerActionProvider = void 0; const zod_1 = require("zod"); const actionProvider_1 = require("../actionProvider"); const actionDecorator_1 = require("../actionDecorator"); const wallet_providers_1 = require("../../wallet-providers"); const schemas_1 = require("./schemas"); const utils_1 = require("./utils"); /** * ClankerActionProvider provides actions for clanker operations. * * @description * This provider is designed to work with EvmWalletProvider for blockchain interactions. * It supports all evm networks. */ class ClankerActionProvider extends actionProvider_1.ActionProvider { /** * Constructor for the ClankerActionProvider. */ constructor() { super("clanker", []); } /** * Clanker action provider * * @description * This action deploys a clanker token using the Clanker sdk * It automatically includes the coin in the Clanker ecosystem * * @param walletProvider - The wallet provider instance for blockchain interactions * @param args - Clanker arguments (modify these to fine tune token deployment, like initial quote token and rewards config) * @returns A promise that resolves to a string describing the clanker result */ async clankToken(walletProvider, args) { const network = walletProvider.getNetwork(); const networkId = network.networkId || "base-mainnet"; if (!this.supportsNetwork(network)) { return `Can't Clank token; network ${networkId} is not supported`; } const clanker = await (0, utils_1.createClankerClient)(walletProvider, networkId); const lockDuration = args.lockDuration_Days * 24 * 60 * 60; const vestingDuration = args.vestingDuration_Days * 24 * 60 * 60; const tokenConfig = { name: args.tokenName, symbol: args.tokenSymbol, image: args.image, metadata: { socialMediaUrls: args.socialMediaUrls, description: args.description, }, context: { interface: args.interface, id: args.id, }, tokenAdmin: walletProvider.getAddress(), vault: { percentage: args.vaultPercentage, lockupDuration: lockDuration, vestingDuration: vestingDuration, }, chainId: Number(network.chainId), }; try { const res = await clanker.deploy(tokenConfig); if ("error" in res) { return `There was an error deploying the clanker token: ${res}`; } const { txHash } = res; const confirmed = await res.waitForTransaction(); if ("error" in confirmed) { return `There was an error confirming the clanker token deployment: ${confirmed}`; } const { address } = confirmed; return `Clanker token deployed at ${address}! View the transaction at ${txHash}, or view the token page at https://clanker.world/clanker/${address}`; } catch (error) { return `There was an error deploying the clanker token: ${error}`; } } /** * Checks if this provider supports the given network. * * @param network - The network to check support for * @returns True if the network is supported */ supportsNetwork(network) { return (network.networkId === "base-mainnet" || network.networkId === "base-sepolia" || network.networkId === "arbitrum-mainnet"); } } exports.ClankerActionProvider = ClankerActionProvider; __decorate([ (0, actionDecorator_1.CreateAction)({ name: "clank_token", description: ` his tool will launch a Clanker token using the Clanker SDK. It takes the following inputs: - tokenName: The name of the deployed token - tokenSymbol: The symbol of the deployed token - description: An optional description of the token or token project - socialMediaUrls: An optional array of social media links for the token, each with a platform and url - image: A normal or ipfs URL pointing to the image of the token - vaultPercentage: The percentage of the token supply to allocate to a vault accessible to the deployed after the lockup period with optional vesting - lockDuration_Days: The lock duration of the tokens in the vault (in days) (minimum 7 days) - vestingDuration_Days: The duration (in days) that the token should vest after lockup period, vesting is linear. `, schema: schemas_1.ClankTokenSchema, }), __metadata("design:type", Function), __metadata("design:paramtypes", [wallet_providers_1.EvmWalletProvider, void 0]), __metadata("design:returntype", Promise) ], ClankerActionProvider.prototype, "clankToken", null); /** * Factory function to create a new ClankerActionProvider instance. * * @returns A new ClankerActionProvider instance */ const clankerActionProvider = () => new ClankerActionProvider(); exports.clankerActionProvider = clankerActionProvider;