From 9e0b91a75b54b080cf6e8c965a6483884c573206 Mon Sep 17 00:00:00 2001 From: RodrigoAD <15104916+RodrigoAD@users.noreply.github.com> Date: Tue, 24 May 2022 14:40:02 +0200 Subject: [PATCH 1/4] start oz erc20 package --- .../gauntlet-starknet-cli/package.json | 4 +- .../gauntlet-starknet-cli/src/index.ts | 4 +- .../gauntlet-starknet-oz-erc20/LICENSE | 21 ++++ .../gauntlet-starknet-oz-erc20/README.md | 2 + .../gauntlet-starknet-oz-erc20/package.json | 32 +++++ .../src/commands/index.ts | 3 + .../src/commands/token/deploy.ts | 95 ++++++++++++++ .../src/commands/token/index.ts | 2 + .../gauntlet-starknet-oz-erc20/src/index.ts | 36 ++++++ .../src/lib/categories.ts | 5 + .../src/lib/contracts.ts | 12 ++ .../gauntlet-starknet-oz-erc20/tsconfig.json | 9 ++ .../src/commands/base/executeCommand.ts | 6 +- .../src/dependencies/index.ts | 2 +- .../gauntlet-starknet/src/wallet/index.ts | 17 ++- tsconfig.json | 3 + yarn.lock | 119 +----------------- 17 files changed, 244 insertions(+), 128 deletions(-) create mode 100644 packages-ts/gauntlet-starknet-oz-erc20/LICENSE create mode 100644 packages-ts/gauntlet-starknet-oz-erc20/README.md create mode 100644 packages-ts/gauntlet-starknet-oz-erc20/package.json create mode 100644 packages-ts/gauntlet-starknet-oz-erc20/src/commands/index.ts create mode 100644 packages-ts/gauntlet-starknet-oz-erc20/src/commands/token/deploy.ts create mode 100644 packages-ts/gauntlet-starknet-oz-erc20/src/commands/token/index.ts create mode 100644 packages-ts/gauntlet-starknet-oz-erc20/src/index.ts create mode 100644 packages-ts/gauntlet-starknet-oz-erc20/src/lib/categories.ts create mode 100644 packages-ts/gauntlet-starknet-oz-erc20/src/lib/contracts.ts create mode 100644 packages-ts/gauntlet-starknet-oz-erc20/tsconfig.json diff --git a/packages-ts/gauntlet-starknet-cli/package.json b/packages-ts/gauntlet-starknet-cli/package.json index 24d5e3612..2d4445dca 100644 --- a/packages-ts/gauntlet-starknet-cli/package.json +++ b/packages-ts/gauntlet-starknet-cli/package.json @@ -26,7 +26,9 @@ }, "dependencies": { "@chainlink/gauntlet-core": "0.3.0", + "@chainlink/gauntlet-starknet-account": "*", "@chainlink/gauntlet-starknet-example": "*", - "@chainlink/gauntlet-starknet-ocr2": "*" + "@chainlink/gauntlet-starknet-ocr2": "*", + "@chainlink/gauntlet-starknet-oz-erc20": "*" } } diff --git a/packages-ts/gauntlet-starknet-cli/src/index.ts b/packages-ts/gauntlet-starknet-cli/src/index.ts index ffdff4821..52b3f8c60 100644 --- a/packages-ts/gauntlet-starknet-cli/src/index.ts +++ b/packages-ts/gauntlet-starknet-cli/src/index.ts @@ -1,13 +1,15 @@ import OCR2Commands from '@chainlink/gauntlet-starknet-ocr2' import ExampleCommands from '@chainlink/gauntlet-starknet-example' import AccountCommands from '@chainlink/gauntlet-starknet-account' +import ERC20Commands from '@chainlink/gauntlet-starknet-oz-erc20' + import { executeCLI } from '@chainlink/gauntlet-core' import { existsSync } from 'fs' import path from 'path' import { io } from '@chainlink/gauntlet-core/dist/utils' const commands = { - custom: [...OCR2Commands, ...ExampleCommands, ...AccountCommands], + custom: [...OCR2Commands, ...ExampleCommands, ...AccountCommands, ...ERC20Commands], loadDefaultFlags: () => ({}), abstract: { findPolymorphic: () => undefined, diff --git a/packages-ts/gauntlet-starknet-oz-erc20/LICENSE b/packages-ts/gauntlet-starknet-oz-erc20/LICENSE new file mode 100644 index 000000000..1ad4f08b3 --- /dev/null +++ b/packages-ts/gauntlet-starknet-oz-erc20/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2022 SmartContract ChainLink, Ltd. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages-ts/gauntlet-starknet-oz-erc20/README.md b/packages-ts/gauntlet-starknet-oz-erc20/README.md new file mode 100644 index 000000000..d6c889709 --- /dev/null +++ b/packages-ts/gauntlet-starknet-oz-erc20/README.md @@ -0,0 +1,2 @@ +# Gauntlet Starknet Commands for the OZ ERC20 Contract + diff --git a/packages-ts/gauntlet-starknet-oz-erc20/package.json b/packages-ts/gauntlet-starknet-oz-erc20/package.json new file mode 100644 index 000000000..76a8f737b --- /dev/null +++ b/packages-ts/gauntlet-starknet-oz-erc20/package.json @@ -0,0 +1,32 @@ +{ + "name": "@chainlink/gauntlet-starknet-oz-erc20", + "version": "0.0.1", + "description": "Gauntlet Starknet OpenZeppelin ERC20", + "keywords": [ + "typescript", + "cli" + ], + "main": "./dist/index.js", + "types": "dist/index.d.ts", + "files": [ + "dist/**/*", + "!dist/**/*.test.js" + ], + "scripts": { + "gauntlet": "ts-node ./src/index.ts", + "lint": "tsc", + "test": "SKIP_PROMPTS=true jest --runInBand", + "test:coverage": "yarn test --collectCoverage", + "test:ci": "yarn test --ci", + "lint:format": "yarn prettier --check ./src", + "format": "yarn prettier --write ./src", + "clean": "rm -rf ./dist/ ./bin/", + "build": "yarn clean && tsc -b", + "bundle": "yarn build && pkg ." + }, + "dependencies": { + "@chainlink/gauntlet-core": "0.3.0", + "@chainlink/gauntlet-starknet": "*", + "starknet": "^3.11.0" + } +} diff --git a/packages-ts/gauntlet-starknet-oz-erc20/src/commands/index.ts b/packages-ts/gauntlet-starknet-oz-erc20/src/commands/index.ts new file mode 100644 index 000000000..a1b522795 --- /dev/null +++ b/packages-ts/gauntlet-starknet-oz-erc20/src/commands/index.ts @@ -0,0 +1,3 @@ +import Token from './token' + +export default [...Token] diff --git a/packages-ts/gauntlet-starknet-oz-erc20/src/commands/token/deploy.ts b/packages-ts/gauntlet-starknet-oz-erc20/src/commands/token/deploy.ts new file mode 100644 index 000000000..437d85603 --- /dev/null +++ b/packages-ts/gauntlet-starknet-oz-erc20/src/commands/token/deploy.ts @@ -0,0 +1,95 @@ +import { BN } from '@chainlink/gauntlet-core/dist/utils' +import { + AfterExecute, + BeforeExecute, + ExecuteCommandConfig, + ExecutionContext, + makeExecuteCommand, + Validation, +} from '@chainlink/gauntlet-starknet' +import { shortString } from 'starknet' +import { CATEGORIES } from '../../lib/categories' +import { contractLoader } from '../../lib/contracts' + +type UserInput = { + name: string + symbol: string + decimals: string + initialSupply: string + recipient?: string + owner?: string +} + +type ContractInput = [ + name: string, + symbol: string, + decimals: string, + initial_supply: string, + recipient: string, + owner: string, +] + +const makeUserInput = async (flags, args): Promise => { + if (flags.input) return flags.input as UserInput + + if (flags.link) { + return { + name: 'Chainlink LINK Token', + symbol: 'LINK', + decimals: '18', + initialSupply: '10000000', + } + } + + return { + name: flags.name, + symbol: flags.symbol, + decimals: flags.decimals, + initialSupply: flags.initialSupply, + recipient: flags.recipient, + owner: flags.owner, + } +} + +const makeContractInput = async (input: UserInput, context: ExecutionContext): Promise => { + const defaultWallet = context.wallet.getAccountPublicKey() + return [ + shortString.encodeShortString(input.name), + shortString.encodeShortString(input.symbol), + input.decimals, + new BN(input.initialSupply).toString(), + input.recipient || defaultWallet, + input.owner || defaultWallet, + ] +} + +const validate: Validation = async (input) => { + // todo: validate every fiels exists + return true +} + +const beforeExecute: BeforeExecute = (context, input, deps) => async () => { + deps.logger.info(`About to deploy an ERC20 Token Contract with the following details: + ${input.contract} + `) +} + +const commandConfig: ExecuteCommandConfig = { + ux: { + category: CATEGORIES.TOKEN, + function: 'deploy', + examples: [ + `${CATEGORIES.TOKEN}:deploy --network= --link`, + `${CATEGORIES.TOKEN}:deploy --network= --link`, + ], + }, + makeUserInput, + makeContractInput, + validations: [validate], + loadContract: contractLoader, + hooks: { + beforeExecute, + }, +} + +export default makeExecuteCommand(commandConfig) diff --git a/packages-ts/gauntlet-starknet-oz-erc20/src/commands/token/index.ts b/packages-ts/gauntlet-starknet-oz-erc20/src/commands/token/index.ts new file mode 100644 index 000000000..2a9000aab --- /dev/null +++ b/packages-ts/gauntlet-starknet-oz-erc20/src/commands/token/index.ts @@ -0,0 +1,2 @@ +import Deploy from './deploy' +export default [Deploy] diff --git a/packages-ts/gauntlet-starknet-oz-erc20/src/index.ts b/packages-ts/gauntlet-starknet-oz-erc20/src/index.ts new file mode 100644 index 000000000..1b382fcdf --- /dev/null +++ b/packages-ts/gauntlet-starknet-oz-erc20/src/index.ts @@ -0,0 +1,36 @@ +import { logger, prompt } from '@chainlink/gauntlet-core/dist/utils' +import { + ExecuteCommandInstance, + CommandCtor, + makeWallet, + makeProvider, + Dependencies, + Env, +} from '@chainlink/gauntlet-starknet' + +import Commands from './commands' + +const registerExecuteCommand = ( + registerCommand: (deps: Dependencies) => CommandCtor>, +) => { + const deps: Dependencies = { + logger: logger, + prompt: prompt, + makeEnv: (flags) => { + const env: Env = { + providerUrl: process.env.NODE_URL || 'https://alpha4.starknet.io', + pk: process.env.PRIVATE_KEY, + account: process.env.ACCOUNT, + } + return env + }, + makeProvider: makeProvider, + makeWallet: makeWallet, + } + return registerCommand(deps) +} + +const registeredCommands = Commands.map(registerExecuteCommand) + +export { Commands } +export default [...registeredCommands] diff --git a/packages-ts/gauntlet-starknet-oz-erc20/src/lib/categories.ts b/packages-ts/gauntlet-starknet-oz-erc20/src/lib/categories.ts new file mode 100644 index 000000000..c4061c4ea --- /dev/null +++ b/packages-ts/gauntlet-starknet-oz-erc20/src/lib/categories.ts @@ -0,0 +1,5 @@ +import { CONTRACT_LIST } from './contracts' + +export const CATEGORIES = { + TOKEN: CONTRACT_LIST.TOKEN, +} diff --git a/packages-ts/gauntlet-starknet-oz-erc20/src/lib/contracts.ts b/packages-ts/gauntlet-starknet-oz-erc20/src/lib/contracts.ts new file mode 100644 index 000000000..595bc672e --- /dev/null +++ b/packages-ts/gauntlet-starknet-oz-erc20/src/lib/contracts.ts @@ -0,0 +1,12 @@ +import fs from 'fs' +import { CompiledContract, json } from 'starknet' + +export enum CONTRACT_LIST { + TOKEN = 'oz_erc20', +} + +export const loadContract = (name: CONTRACT_LIST): CompiledContract => { + return json.parse(fs.readFileSync(`${__dirname}/../../artifacts/abi/${name}.json`).toString('ascii')) +} + +export const contractLoader = () => loadContract(CONTRACT_LIST.TOKEN) diff --git a/packages-ts/gauntlet-starknet-oz-erc20/tsconfig.json b/packages-ts/gauntlet-starknet-oz-erc20/tsconfig.json new file mode 100644 index 000000000..2c84c1fcb --- /dev/null +++ b/packages-ts/gauntlet-starknet-oz-erc20/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "dist", + "rootDir": "src" + }, + "include": ["src/**/*"], + "exclude": ["dist", "**/*.spec.ts", "**/*.test.ts"] +} diff --git a/packages-ts/gauntlet-starknet/src/commands/base/executeCommand.ts b/packages-ts/gauntlet-starknet/src/commands/base/executeCommand.ts index 3ad5a3f01..cc21286cf 100644 --- a/packages-ts/gauntlet-starknet/src/commands/base/executeCommand.ts +++ b/packages-ts/gauntlet-starknet/src/commands/base/executeCommand.ts @@ -39,7 +39,7 @@ export interface ExecuteCommandConfig { afterExecute?: AfterExecute } makeUserInput: (flags, args) => Promise - makeContractInput: (userInput: UI) => Promise + makeContractInput: (userInput: UI, context: ExecutionContext) => Promise validations: Validation[] loadContract: () => CompiledContract } @@ -85,7 +85,7 @@ export const makeExecuteCommand = (config: ExecuteCommandConfig) const env = deps.makeEnv(flags) c.provider = deps.makeProvider(env.providerUrl) - c.wallet = deps.makeWallet(env.pk) + c.wallet = deps.makeWallet(env.pk, env.account) c.contractAddress = args[0] c.account = env.account @@ -137,7 +137,7 @@ export const makeExecuteCommand = (config: ExecuteCommandConfig) await this.runValidations(config.validations, userInput) } - const contractInput = await config.makeContractInput(userInput) + const contractInput = await config.makeContractInput(userInput, this.executionContext) return { user: userInput, diff --git a/packages-ts/gauntlet-starknet/src/dependencies/index.ts b/packages-ts/gauntlet-starknet/src/dependencies/index.ts index 6c0057169..555867bc8 100644 --- a/packages-ts/gauntlet-starknet/src/dependencies/index.ts +++ b/packages-ts/gauntlet-starknet/src/dependencies/index.ts @@ -12,6 +12,6 @@ export interface Dependencies { logger: typeof logger prompt: typeof prompt makeProvider: (url: string) => IStarknetProvider - makeWallet: (pk: string) => IStarknetWallet + makeWallet: (pk: string, account?: string) => IStarknetWallet makeEnv: (flags: Record) => Env } diff --git a/packages-ts/gauntlet-starknet/src/wallet/index.ts b/packages-ts/gauntlet-starknet/src/wallet/index.ts index 71341b1ee..624b8be44 100644 --- a/packages-ts/gauntlet-starknet/src/wallet/index.ts +++ b/packages-ts/gauntlet-starknet/src/wallet/index.ts @@ -5,25 +5,30 @@ export interface IWallet { getPublicKey: () => Promise } -export interface IStarknetWallet extends IWallet {} +export interface IStarknetWallet extends IWallet { + getAccountPublicKey: () => string +} -export const makeWallet = (rawPk?: string) => { - return Wallet.create(rawPk) +export const makeWallet = (rawPk?: string, account?: string) => { + return Wallet.create(rawPk, account) } class Wallet implements IStarknetWallet { wallet: Signer + account: string - private constructor(keypair: KeyPair) { + private constructor(keypair: KeyPair, account?: string) { this.wallet = new Signer(keypair) + this.account = account } - static create = (pKey: string) => { + static create = (pKey: string, account?: string) => { const keyPair = ec.getKeyPair(pKey) - return new Wallet(keyPair) + return new Wallet(keyPair, account) } sign = () => {} getPublicKey = async () => await this.wallet.getPubKey() + getAccountPublicKey = () => this.account } diff --git a/tsconfig.json b/tsconfig.json index 7bb275e5c..59580d45b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,6 +12,9 @@ { "path": "./packages-ts/gauntlet-starknet-account" }, + { + "path": "./packages-ts/gauntlet-starknet-oz-erc20" + }, { "path": "./packages-ts/gauntlet-starknet-ocr2" }, diff --git a/yarn.lock b/yarn.lock index 69d166046..ddd34348a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -748,13 +748,6 @@ resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.6.0.tgz#efcbd41937f9ae7434c714ab698604822d890759" integrity sha512-G/AdOadiZhnJp0jXCaBQU449W2h716OW/EoXeYkCytxKL06X1WCXB4DZpp8TpZ8eyIJVS1cw4lrlkkSYU21cDw== -"@types/secp256k1@^4.0.3": - version "4.0.3" - resolved "https://registry.yarnpkg.com/@types/secp256k1/-/secp256k1-4.0.3.tgz#1b8e55d8e00f08ee7220b4d59a6abe89c37a901c" - integrity sha512-Da66lEIFeIz9ltsdMZcpQvmrmmoqrfju8pm1BH8WbYjZSwUgCwXLb9C+9XYogwBITnbsSaMdVPb2ekf7TV+03w== - dependencies: - "@types/node" "*" - "@types/stack-utils@^2.0.0": version "2.0.1" resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.1.tgz#20f18294f797f2209b5f65c8e3b5c8e8261d127c" @@ -1036,11 +1029,6 @@ bl@^4.0.3: inherits "^2.0.4" readable-stream "^3.4.0" -bluebird@^3.5.0: - version "3.7.2" - resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" - integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== - bn.js@^4.11.9: version "4.12.0" resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.12.0.tgz#775b3f278efbb9718eec7361f483fb36fbbfea88" @@ -1145,18 +1133,6 @@ cache-base@^1.0.1: union-value "^1.0.0" unset-value "^1.0.0" -cairo-ls@^0.0.4: - version "0.0.4" - resolved "https://registry.yarnpkg.com/cairo-ls/-/cairo-ls-0.0.4.tgz#42c4eae4c1eac65eed32fe66896fcc44531ddffc" - integrity sha512-n/dWpvbt0g2ioQZJAneCgFe0kxMo6LncSF/GwdjffbjRJC/gCCGrYNPoa3OgKCoLwGBny+DwXiJhJY5UPV5pdw== - dependencies: - file-uri-to-path "^2.0.0" - glob "^7.2.0" - index-of-regex "^1.0.0" - request-promise "4.2.5" - vscode-languageserver "^6.1.1" - vscode-languageserver-textdocument "^1.0.1" - callsites@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" @@ -1723,11 +1699,6 @@ fb-watchman@^2.0.0: dependencies: bser "2.1.1" -file-uri-to-path@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-2.0.0.tgz#7b415aeba227d575851e0a5b0c640d7656403fba" - integrity sha512-hjPFI8oE/2iQPVe4gbrJ73Pp+Xfub2+WI2LlXDbsaJBwT5wuMh35WNWVYYTpnz895shtwfyutMFLFywpQAFdLg== - fill-range@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7" @@ -1877,7 +1848,7 @@ glob-parent@^5.1.2: dependencies: is-glob "^4.0.1" -glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4, glob@^7.2.0: +glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4: version "7.2.0" resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023" integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q== @@ -2055,11 +2026,6 @@ imurmurhash@^0.1.4: resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" integrity sha1-khi5srkoojixPcT7a21XbyMUU+o= -index-of-regex@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/index-of-regex/-/index-of-regex-1.0.0.tgz#3a7637b4e27665f6673a4751a20b01477ffbd3ec" - integrity sha1-OnY3tOJ2ZfZnOkdRogsBR3/70+w= - inflight@^1.0.4: version "1.0.6" resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" @@ -2836,7 +2802,7 @@ locate-path@^5.0.0: dependencies: p-locate "^4.1.0" -lodash@4.x, lodash@^4.17.15, lodash@^4.7.0: +lodash@4.x, lodash@^4.7.0: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== @@ -3045,11 +3011,6 @@ node-abi@^2.21.0: dependencies: semver "^5.4.1" -node-addon-api@^2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-2.0.2.tgz#432cfa82962ce494b132e9d72a15b29f71ff5d32" - integrity sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA== - node-fetch@^2.6.6: version "2.6.7" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" @@ -3057,11 +3018,6 @@ node-fetch@^2.6.6: dependencies: whatwg-url "^5.0.0" -node-gyp-build@^4.2.0: - version "4.4.0" - resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.4.0.tgz#42e99687ce87ddeaf3a10b99dc06abc11021f3f4" - integrity sha512-amJnQCcgtRVw9SvoebO3BKGESClrfXGCUTX9hSn1OuGQTQBOZmVd0Z0OlecpuRksKvbsUqALE8jls/ErClAPuQ== - node-int64@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b" @@ -3421,7 +3377,7 @@ protobufjs@^6.11.2: "@types/node" ">=13.7.0" long "^4.0.0" -psl@^1.1.28, psl@^1.1.33: +psl@^1.1.33: version "1.8.0" resolved "https://registry.yarnpkg.com/psl/-/psl-1.8.0.tgz#9326f8bcfb013adcc005fdff056acce020e51c24" integrity sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ== @@ -3523,23 +3479,6 @@ repeat-string@^1.6.1: resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" integrity sha1-jcrkcOHIirwtYA//Sndihtp15jc= -request-promise-core@1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/request-promise-core/-/request-promise-core-1.1.3.tgz#e9a3c081b51380dfea677336061fea879a829ee9" - integrity sha512-QIs2+ArIGQVp5ZYbWD5ZLCY29D5CfWizP8eWnm8FoGD1TX61veauETVQbrV60662V0oFBkrDOuaBI8XgtuyYAQ== - dependencies: - lodash "^4.17.15" - -request-promise@4.2.5: - version "4.2.5" - resolved "https://registry.yarnpkg.com/request-promise/-/request-promise-4.2.5.tgz#186222c59ae512f3497dfe4d75a9c8461bd0053c" - integrity sha512-ZgnepCykFdmpq86fKGwqntyTiUrHycALuGggpyCZwMvGaZWgxW6yagT0FHkgo5LzYvOaCNvxYwWYIjevSH1EDg== - dependencies: - bluebird "^3.5.0" - request-promise-core "1.1.3" - stealthy-require "^1.1.1" - tough-cookie "^2.3.3" - require-directory@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" @@ -3649,15 +3588,6 @@ saxes@^5.0.1: dependencies: xmlchars "^2.2.0" -secp256k1@^4.0.2: - version "4.0.3" - resolved "https://registry.yarnpkg.com/secp256k1/-/secp256k1-4.0.3.tgz#c4559ecd1b8d3c1827ed2d1b94190d69ce267303" - integrity sha512-NLZVf+ROMxwtEj3Xa562qgv2BK5e2WNmXPiOdVIPLgs6lyTzMvBq0aWTYMI5XCP9jZMVKOcqZLw/Wc4vDkuxhA== - dependencies: - elliptic "^6.5.4" - node-addon-api "^2.0.0" - node-gyp-build "^4.2.0" - "semver@2 || 3 || 4 || 5", semver@^5.4.1, semver@^5.5.0: version "5.7.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" @@ -3887,11 +3817,6 @@ static-extend@^0.1.1: define-property "^0.2.5" object-copy "^0.1.0" -stealthy-require@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/stealthy-require/-/stealthy-require-1.1.1.tgz#35b09875b4ff49f26a777e509b3090a3226bf24b" - integrity sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks= - stream-meter@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/stream-meter/-/stream-meter-1.0.4.tgz#52af95aa5ea760a2491716704dbff90f73afdd1d" @@ -4095,14 +4020,6 @@ to-regex@^3.0.1, to-regex@^3.0.2: regex-not "^1.0.2" safe-regex "^1.1.0" -tough-cookie@^2.3.3: - version "2.5.0" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.5.0.tgz#cd9fb2a0aa1d5a12b473bd9fb96fa3dcff65ade2" - integrity sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g== - dependencies: - psl "^1.1.28" - punycode "^2.1.1" - tough-cookie@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-4.0.0.tgz#d822234eeca882f991f0f908824ad2622ddbece4" @@ -4272,36 +4189,6 @@ validate-npm-package-license@^3.0.1: spdx-correct "^3.0.0" spdx-expression-parse "^3.0.0" -vscode-jsonrpc@8.0.1: - version "8.0.1" - resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-8.0.1.tgz#f30b0625ebafa0fb3bc53e934ca47b706445e57e" - integrity sha512-N/WKvghIajmEvXpatSzvTvOIz61ZSmOSa4BRA4pTLi+1+jozquQKP/MkaylP9iB68k73Oua1feLQvH3xQuigiQ== - -vscode-languageserver-protocol@^3.15.3: - version "3.17.1" - resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.1.tgz#e801762c304f740208b6c804a0cf21f2c87509ed" - integrity sha512-BNlAYgQoYwlSgDLJhSG+DeA8G1JyECqRzM2YO6tMmMji3Ad9Mw6AW7vnZMti90qlAKb0LqAlJfSVGEdqMMNzKg== - dependencies: - vscode-jsonrpc "8.0.1" - vscode-languageserver-types "3.17.1" - -vscode-languageserver-textdocument@^1.0.1: - version "1.0.4" - resolved "https://registry.yarnpkg.com/vscode-languageserver-textdocument/-/vscode-languageserver-textdocument-1.0.4.tgz#3cd56dd14cec1d09e86c4bb04b09a246cb3df157" - integrity sha512-/xhqXP/2A2RSs+J8JNXpiiNVvvNM0oTosNVmQnunlKvq9o4mupHOBAnnzH0lwIPKazXKvAKsVp1kr+H/K4lgoQ== - -vscode-languageserver-types@3.17.1: - version "3.17.1" - resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.17.1.tgz#c2d87fa7784f8cac389deb3ff1e2d9a7bef07e16" - integrity sha512-K3HqVRPElLZVVPtMeKlsyL9aK0GxGQpvtAUTfX4k7+iJ4mc1M+JM+zQwkgGy2LzY0f0IAafe8MKqIkJrxfGGjQ== - -vscode-languageserver@^6.1.1: - version "6.1.1" - resolved "https://registry.yarnpkg.com/vscode-languageserver/-/vscode-languageserver-6.1.1.tgz#d76afc68172c27d4327ee74332b468fbc740d762" - integrity sha512-DueEpkUAkD5XTR4MLYNr6bQIp/UFR0/IPApgXU3YfCBCB08u2sm9hRCs6DxYZELkk++STPjpcjksR2H8qI3cDQ== - dependencies: - vscode-languageserver-protocol "^3.15.3" - w3c-hr-time@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz#0a89cdf5cc15822df9c360543676963e0cc308cd" From d5f19eb48da001fed07e091e46def7d8140d43db Mon Sep 17 00:00:00 2001 From: RodrigoAD <15104916+RodrigoAD@users.noreply.github.com> Date: Thu, 26 May 2022 11:50:42 +0200 Subject: [PATCH 2/4] add starkgate erc20 and argent account --- .../LICENSE | 0 .../gauntlet-starknet-argent/README.md | 31 ++++++++ .../package.json | 4 +- .../src/commands/account/deploy.ts | 44 +++++++++++ .../src/commands/account/index.ts | 4 + .../src/commands/account/initialize.ts | 77 +++++++++++++++++++ .../src/commands/index.ts | 0 .../src/index.ts | 0 .../src/lib/categories.ts | 0 .../src/lib/contracts.ts | 12 +++ .../tsconfig.json | 0 .../gauntlet-starknet-cli/package.json | 5 +- .../gauntlet-starknet-cli/src/index.ts | 7 +- .../gauntlet-starknet-oz-erc20/README.md | 2 - .../src/commands/token/index.ts | 2 - .../LICENSE | 0 .../README.md | 4 +- .../package.json | 4 +- .../src/commands/account/deploy.ts | 0 .../src/commands/account/index.ts | 0 .../src/commands/index.ts | 3 + .../src/index.ts | 0 .../src/lib/categories.ts | 5 ++ .../src/lib/contracts.ts | 2 +- .../tsconfig.json | 0 .../gauntlet-starknet-starkgate/LICENSE | 21 +++++ .../gauntlet-starknet-starkgate/README.md | 28 +++++++ .../gauntlet-starknet-starkgate/package.json | 32 ++++++++ .../src/commands/index.ts | 0 .../src/commands/token/deploy.ts | 23 +----- .../src/commands/token/index.ts | 5 ++ .../src/commands/token/mint.ts | 56 ++++++++++++++ .../src/commands/token/transfer.ts | 64 +++++++++++++++ .../gauntlet-starknet-starkgate/src/index.ts | 36 +++++++++ .../src/lib/categories.ts | 0 .../src/lib/contracts.ts | 2 +- .../gauntlet-starknet-starkgate/tsconfig.json | 9 +++ .../src/commands/base/executeCommand.ts | 13 +++- packages-ts/gauntlet-starknet/src/index.ts | 1 + .../gauntlet-starknet/src/utils/address.ts | 10 +++ .../gauntlet-starknet/src/utils/index.ts | 1 + tsconfig.json | 7 +- 42 files changed, 474 insertions(+), 40 deletions(-) rename packages-ts/{gauntlet-starknet-account => gauntlet-starknet-argent}/LICENSE (100%) create mode 100644 packages-ts/gauntlet-starknet-argent/README.md rename packages-ts/{gauntlet-starknet-account => gauntlet-starknet-argent}/package.json (87%) create mode 100644 packages-ts/gauntlet-starknet-argent/src/commands/account/deploy.ts create mode 100644 packages-ts/gauntlet-starknet-argent/src/commands/account/index.ts create mode 100644 packages-ts/gauntlet-starknet-argent/src/commands/account/initialize.ts rename packages-ts/{gauntlet-starknet-account => gauntlet-starknet-argent}/src/commands/index.ts (100%) rename packages-ts/{gauntlet-starknet-account => gauntlet-starknet-argent}/src/index.ts (100%) rename packages-ts/{gauntlet-starknet-account => gauntlet-starknet-argent}/src/lib/categories.ts (100%) create mode 100644 packages-ts/gauntlet-starknet-argent/src/lib/contracts.ts rename packages-ts/{gauntlet-starknet-account => gauntlet-starknet-argent}/tsconfig.json (100%) delete mode 100644 packages-ts/gauntlet-starknet-oz-erc20/README.md delete mode 100644 packages-ts/gauntlet-starknet-oz-erc20/src/commands/token/index.ts rename packages-ts/{gauntlet-starknet-oz-erc20 => gauntlet-starknet-oz}/LICENSE (100%) rename packages-ts/{gauntlet-starknet-account => gauntlet-starknet-oz}/README.md (88%) rename packages-ts/{gauntlet-starknet-oz-erc20 => gauntlet-starknet-oz}/package.json (87%) rename packages-ts/{gauntlet-starknet-account => gauntlet-starknet-oz}/src/commands/account/deploy.ts (100%) rename packages-ts/{gauntlet-starknet-account => gauntlet-starknet-oz}/src/commands/account/index.ts (100%) create mode 100644 packages-ts/gauntlet-starknet-oz/src/commands/index.ts rename packages-ts/{gauntlet-starknet-oz-erc20 => gauntlet-starknet-oz}/src/index.ts (100%) create mode 100644 packages-ts/gauntlet-starknet-oz/src/lib/categories.ts rename packages-ts/{gauntlet-starknet-account => gauntlet-starknet-oz}/src/lib/contracts.ts (93%) rename packages-ts/{gauntlet-starknet-oz-erc20 => gauntlet-starknet-oz}/tsconfig.json (100%) create mode 100644 packages-ts/gauntlet-starknet-starkgate/LICENSE create mode 100644 packages-ts/gauntlet-starknet-starkgate/README.md create mode 100644 packages-ts/gauntlet-starknet-starkgate/package.json rename packages-ts/{gauntlet-starknet-oz-erc20 => gauntlet-starknet-starkgate}/src/commands/index.ts (100%) rename packages-ts/{gauntlet-starknet-oz-erc20 => gauntlet-starknet-starkgate}/src/commands/token/deploy.ts (79%) create mode 100644 packages-ts/gauntlet-starknet-starkgate/src/commands/token/index.ts create mode 100644 packages-ts/gauntlet-starknet-starkgate/src/commands/token/mint.ts create mode 100644 packages-ts/gauntlet-starknet-starkgate/src/commands/token/transfer.ts create mode 100644 packages-ts/gauntlet-starknet-starkgate/src/index.ts rename packages-ts/{gauntlet-starknet-oz-erc20 => gauntlet-starknet-starkgate}/src/lib/categories.ts (100%) rename packages-ts/{gauntlet-starknet-oz-erc20 => gauntlet-starknet-starkgate}/src/lib/contracts.ts (92%) create mode 100644 packages-ts/gauntlet-starknet-starkgate/tsconfig.json create mode 100644 packages-ts/gauntlet-starknet/src/utils/address.ts create mode 100644 packages-ts/gauntlet-starknet/src/utils/index.ts diff --git a/packages-ts/gauntlet-starknet-account/LICENSE b/packages-ts/gauntlet-starknet-argent/LICENSE similarity index 100% rename from packages-ts/gauntlet-starknet-account/LICENSE rename to packages-ts/gauntlet-starknet-argent/LICENSE diff --git a/packages-ts/gauntlet-starknet-argent/README.md b/packages-ts/gauntlet-starknet-argent/README.md new file mode 100644 index 000000000..616a45991 --- /dev/null +++ b/packages-ts/gauntlet-starknet-argent/README.md @@ -0,0 +1,31 @@ +# Gauntlet Starknet Commands for Argent Contracts + +## Account + +Deploy the contract: + +``` +yarn gauntlet argent_account:deploy --network= +``` + +Note the contract address. The contract is not configured yet. A signer needs to be specified in it: + +Initialize the contract: + +```bash +yarn gauntlet argent_account:initialize --network= +# OR If you already have a private key +yarn gauntlet argent_account:initialize --network= --publicKey= +``` + +If no public key is provided, the command will generate a new Keypair and will give the details during the execution. + +You need to pay some fee to call initialize, but as this could be the first account wallet you are deploying, use the `--noWallet` option to bypass the fee. This will be soon deprecated + +At the end of the process, you will want to include the account contract and the private key to your `.env` configuration file. + +```bash +# .env +PRIVATE_KEY=0x... +ACCOUNT=0x... +``` diff --git a/packages-ts/gauntlet-starknet-account/package.json b/packages-ts/gauntlet-starknet-argent/package.json similarity index 87% rename from packages-ts/gauntlet-starknet-account/package.json rename to packages-ts/gauntlet-starknet-argent/package.json index e99401852..6a48b9d03 100644 --- a/packages-ts/gauntlet-starknet-account/package.json +++ b/packages-ts/gauntlet-starknet-argent/package.json @@ -1,7 +1,7 @@ { - "name": "@chainlink/gauntlet-starknet-account", + "name": "@chainlink/gauntlet-starknet-argent", "version": "0.0.1", - "description": "Gauntlet Starknet Account", + "description": "Gauntlet Starknet Argent contracts", "keywords": [ "typescript", "cli" diff --git a/packages-ts/gauntlet-starknet-argent/src/commands/account/deploy.ts b/packages-ts/gauntlet-starknet-argent/src/commands/account/deploy.ts new file mode 100644 index 000000000..d78a3f202 --- /dev/null +++ b/packages-ts/gauntlet-starknet-argent/src/commands/account/deploy.ts @@ -0,0 +1,44 @@ +import { + BeforeExecute, + ExecuteCommandConfig, + ExecutionContext, + makeExecuteCommand, + Validation, +} from '@chainlink/gauntlet-starknet' +import { CATEGORIES } from '../../lib/categories' +import { accountContractLoader } from '../../lib/contracts' + +type UserInput = {} + +type ContractInput = [] + +const makeUserInput = async (flags, args): Promise => ({}) + +const makeContractInput = async (input: UserInput, context: ExecutionContext): Promise => { + return [] +} + +const validate: Validation = async (input) => { + return true +} + +const beforeExecute: BeforeExecute = (context, input, deps) => async () => { + deps.logger.info(`About to deploy an Argent Account Contract`) +} + +const commandConfig: ExecuteCommandConfig = { + ux: { + category: CATEGORIES.ACCOUNT, + function: 'deploy', + examples: [`${CATEGORIES.ACCOUNT}:deploy --network=`], + }, + makeUserInput, + makeContractInput, + validations: [validate], + loadContract: accountContractLoader, + hooks: { + beforeExecute, + }, +} + +export default makeExecuteCommand(commandConfig) diff --git a/packages-ts/gauntlet-starknet-argent/src/commands/account/index.ts b/packages-ts/gauntlet-starknet-argent/src/commands/account/index.ts new file mode 100644 index 000000000..dc9ac9aa5 --- /dev/null +++ b/packages-ts/gauntlet-starknet-argent/src/commands/account/index.ts @@ -0,0 +1,4 @@ +import Deploy from './deploy' +import Initialize from './initialize' + +export default [Deploy, Initialize] diff --git a/packages-ts/gauntlet-starknet-argent/src/commands/account/initialize.ts b/packages-ts/gauntlet-starknet-argent/src/commands/account/initialize.ts new file mode 100644 index 000000000..e3c5096d6 --- /dev/null +++ b/packages-ts/gauntlet-starknet-argent/src/commands/account/initialize.ts @@ -0,0 +1,77 @@ +import { + AfterExecute, + BeforeExecute, + ExecuteCommandConfig, + makeExecuteCommand, + Validation, +} from '@chainlink/gauntlet-starknet' +import { ec } from 'starknet' +import { CATEGORIES } from '../../lib/categories' +import { accountContractLoader } from '../../lib/contracts' + +type UserInput = { + publicKey: string + privateKey?: string +} + +type ContractInput = [string, 0] + +const makeUserInput = async (flags, args): Promise => { + if (flags.input) return flags.input as UserInput + + // If public key is not provided, generate a new address + const keypair = ec.genKeyPair() + const generatedPK = '0x' + keypair.getPrivate('hex') + const pubkey = flags.publicKey || ec.getStarkKey(ec.getKeyPair(generatedPK)) + return { + publicKey: pubkey, + privateKey: !flags.publicKey && generatedPK, + } +} + +const makeContractInput = async (input: UserInput): Promise => { + return [input.publicKey, 0] +} + +const validate: Validation = async (input) => { + return true +} + +const beforeExecute: BeforeExecute = (context, input, deps) => async () => { + deps.logger.info(`About to deploy an Account Contract with public key ${input.contract[0]}`) + if (input.user.privateKey) { + await deps.prompt(`The generated private key will be shown next, continue?`) + deps.logger.line() + + deps.logger.info(`To sign future transactions, store the Private Key`) + deps.logger.info(`PRIVATE_KEY: ${input.user.privateKey}`) + + deps.logger.line() + } +} + +const afterExecute: AfterExecute = (context, input, deps) => async (result) => { + deps.logger.success(`Account contract located at ${result.responses[0].tx.address}`) + return { + publicKey: input.user.publicKey, + privateKey: input.user.privateKey, + } +} + +const commandConfig: ExecuteCommandConfig = { + ux: { + category: CATEGORIES.ACCOUNT, + function: 'initialize', + examples: [`${CATEGORIES.ACCOUNT}:initialize --network= --publicKey=
`], + }, + makeUserInput, + makeContractInput, + validations: [validate], + loadContract: accountContractLoader, + hooks: { + beforeExecute, + afterExecute, + }, +} + +export default makeExecuteCommand(commandConfig) diff --git a/packages-ts/gauntlet-starknet-account/src/commands/index.ts b/packages-ts/gauntlet-starknet-argent/src/commands/index.ts similarity index 100% rename from packages-ts/gauntlet-starknet-account/src/commands/index.ts rename to packages-ts/gauntlet-starknet-argent/src/commands/index.ts diff --git a/packages-ts/gauntlet-starknet-account/src/index.ts b/packages-ts/gauntlet-starknet-argent/src/index.ts similarity index 100% rename from packages-ts/gauntlet-starknet-account/src/index.ts rename to packages-ts/gauntlet-starknet-argent/src/index.ts diff --git a/packages-ts/gauntlet-starknet-account/src/lib/categories.ts b/packages-ts/gauntlet-starknet-argent/src/lib/categories.ts similarity index 100% rename from packages-ts/gauntlet-starknet-account/src/lib/categories.ts rename to packages-ts/gauntlet-starknet-argent/src/lib/categories.ts diff --git a/packages-ts/gauntlet-starknet-argent/src/lib/contracts.ts b/packages-ts/gauntlet-starknet-argent/src/lib/contracts.ts new file mode 100644 index 000000000..1bbdc3042 --- /dev/null +++ b/packages-ts/gauntlet-starknet-argent/src/lib/contracts.ts @@ -0,0 +1,12 @@ +import fs from 'fs' +import { CompiledContract, json } from 'starknet' + +export enum CONTRACT_LIST { + ACCOUNT = 'argent_account', +} + +export const loadContract = (name: CONTRACT_LIST): CompiledContract => { + return json.parse(fs.readFileSync(`${__dirname}/../../artifacts/abi/${name}.json`).toString('ascii')) +} + +export const accountContractLoader = () => loadContract(CONTRACT_LIST.ACCOUNT) diff --git a/packages-ts/gauntlet-starknet-account/tsconfig.json b/packages-ts/gauntlet-starknet-argent/tsconfig.json similarity index 100% rename from packages-ts/gauntlet-starknet-account/tsconfig.json rename to packages-ts/gauntlet-starknet-argent/tsconfig.json diff --git a/packages-ts/gauntlet-starknet-cli/package.json b/packages-ts/gauntlet-starknet-cli/package.json index 2d4445dca..592df4f36 100644 --- a/packages-ts/gauntlet-starknet-cli/package.json +++ b/packages-ts/gauntlet-starknet-cli/package.json @@ -26,9 +26,10 @@ }, "dependencies": { "@chainlink/gauntlet-core": "0.3.0", - "@chainlink/gauntlet-starknet-account": "*", + "@chainlink/gauntlet-starknet-oz": "*", + "@chainlink/gauntlet-starknet-argent": "*", "@chainlink/gauntlet-starknet-example": "*", "@chainlink/gauntlet-starknet-ocr2": "*", - "@chainlink/gauntlet-starknet-oz-erc20": "*" + "@chainlink/gauntlet-starknet-starkgate": "*" } } diff --git a/packages-ts/gauntlet-starknet-cli/src/index.ts b/packages-ts/gauntlet-starknet-cli/src/index.ts index 52b3f8c60..4beb9db39 100644 --- a/packages-ts/gauntlet-starknet-cli/src/index.ts +++ b/packages-ts/gauntlet-starknet-cli/src/index.ts @@ -1,7 +1,8 @@ import OCR2Commands from '@chainlink/gauntlet-starknet-ocr2' import ExampleCommands from '@chainlink/gauntlet-starknet-example' -import AccountCommands from '@chainlink/gauntlet-starknet-account' -import ERC20Commands from '@chainlink/gauntlet-starknet-oz-erc20' +import OZCommands from '@chainlink/gauntlet-starknet-oz' +import StarkgateCommands from '@chainlink/gauntlet-starknet-starkgate' +import ArgentCommands from '@chainlink/gauntlet-starknet-argent' import { executeCLI } from '@chainlink/gauntlet-core' import { existsSync } from 'fs' @@ -9,7 +10,7 @@ import path from 'path' import { io } from '@chainlink/gauntlet-core/dist/utils' const commands = { - custom: [...OCR2Commands, ...ExampleCommands, ...AccountCommands, ...ERC20Commands], + custom: [...OCR2Commands, ...ExampleCommands, ...OZCommands, ...StarkgateCommands, ...ArgentCommands], loadDefaultFlags: () => ({}), abstract: { findPolymorphic: () => undefined, diff --git a/packages-ts/gauntlet-starknet-oz-erc20/README.md b/packages-ts/gauntlet-starknet-oz-erc20/README.md deleted file mode 100644 index d6c889709..000000000 --- a/packages-ts/gauntlet-starknet-oz-erc20/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# Gauntlet Starknet Commands for the OZ ERC20 Contract - diff --git a/packages-ts/gauntlet-starknet-oz-erc20/src/commands/token/index.ts b/packages-ts/gauntlet-starknet-oz-erc20/src/commands/token/index.ts deleted file mode 100644 index 2a9000aab..000000000 --- a/packages-ts/gauntlet-starknet-oz-erc20/src/commands/token/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -import Deploy from './deploy' -export default [Deploy] diff --git a/packages-ts/gauntlet-starknet-oz-erc20/LICENSE b/packages-ts/gauntlet-starknet-oz/LICENSE similarity index 100% rename from packages-ts/gauntlet-starknet-oz-erc20/LICENSE rename to packages-ts/gauntlet-starknet-oz/LICENSE diff --git a/packages-ts/gauntlet-starknet-account/README.md b/packages-ts/gauntlet-starknet-oz/README.md similarity index 88% rename from packages-ts/gauntlet-starknet-account/README.md rename to packages-ts/gauntlet-starknet-oz/README.md index aa5cf0d54..8df81009a 100644 --- a/packages-ts/gauntlet-starknet-account/README.md +++ b/packages-ts/gauntlet-starknet-oz/README.md @@ -1,6 +1,6 @@ -# Gauntlet Starknet Commands for the Account Contract +# Gauntlet Starknet Commands for the Open Zeppelin Contracts -## Setup an account +## Account Run the following command: diff --git a/packages-ts/gauntlet-starknet-oz-erc20/package.json b/packages-ts/gauntlet-starknet-oz/package.json similarity index 87% rename from packages-ts/gauntlet-starknet-oz-erc20/package.json rename to packages-ts/gauntlet-starknet-oz/package.json index 76a8f737b..96bae2ba9 100644 --- a/packages-ts/gauntlet-starknet-oz-erc20/package.json +++ b/packages-ts/gauntlet-starknet-oz/package.json @@ -1,7 +1,7 @@ { - "name": "@chainlink/gauntlet-starknet-oz-erc20", + "name": "@chainlink/gauntlet-starknet-oz", "version": "0.0.1", - "description": "Gauntlet Starknet OpenZeppelin ERC20", + "description": "Gauntlet Starknet Open Zeppelin Contracts", "keywords": [ "typescript", "cli" diff --git a/packages-ts/gauntlet-starknet-account/src/commands/account/deploy.ts b/packages-ts/gauntlet-starknet-oz/src/commands/account/deploy.ts similarity index 100% rename from packages-ts/gauntlet-starknet-account/src/commands/account/deploy.ts rename to packages-ts/gauntlet-starknet-oz/src/commands/account/deploy.ts diff --git a/packages-ts/gauntlet-starknet-account/src/commands/account/index.ts b/packages-ts/gauntlet-starknet-oz/src/commands/account/index.ts similarity index 100% rename from packages-ts/gauntlet-starknet-account/src/commands/account/index.ts rename to packages-ts/gauntlet-starknet-oz/src/commands/account/index.ts diff --git a/packages-ts/gauntlet-starknet-oz/src/commands/index.ts b/packages-ts/gauntlet-starknet-oz/src/commands/index.ts new file mode 100644 index 000000000..4924c4a0d --- /dev/null +++ b/packages-ts/gauntlet-starknet-oz/src/commands/index.ts @@ -0,0 +1,3 @@ +import Account from './account' + +export default [...Account] diff --git a/packages-ts/gauntlet-starknet-oz-erc20/src/index.ts b/packages-ts/gauntlet-starknet-oz/src/index.ts similarity index 100% rename from packages-ts/gauntlet-starknet-oz-erc20/src/index.ts rename to packages-ts/gauntlet-starknet-oz/src/index.ts diff --git a/packages-ts/gauntlet-starknet-oz/src/lib/categories.ts b/packages-ts/gauntlet-starknet-oz/src/lib/categories.ts new file mode 100644 index 000000000..e9005bb80 --- /dev/null +++ b/packages-ts/gauntlet-starknet-oz/src/lib/categories.ts @@ -0,0 +1,5 @@ +import { CONTRACT_LIST } from './contracts' + +export const CATEGORIES = { + ACCOUNT: CONTRACT_LIST.ACCOUNT, +} diff --git a/packages-ts/gauntlet-starknet-account/src/lib/contracts.ts b/packages-ts/gauntlet-starknet-oz/src/lib/contracts.ts similarity index 93% rename from packages-ts/gauntlet-starknet-account/src/lib/contracts.ts rename to packages-ts/gauntlet-starknet-oz/src/lib/contracts.ts index 672deed70..33b782a0f 100644 --- a/packages-ts/gauntlet-starknet-account/src/lib/contracts.ts +++ b/packages-ts/gauntlet-starknet-oz/src/lib/contracts.ts @@ -2,7 +2,7 @@ import fs from 'fs' import { CompiledContract, json } from 'starknet' export enum CONTRACT_LIST { - ACCOUNT = 'account', + ACCOUNT = 'oz_account', } export const loadContract = (name: CONTRACT_LIST): CompiledContract => { diff --git a/packages-ts/gauntlet-starknet-oz-erc20/tsconfig.json b/packages-ts/gauntlet-starknet-oz/tsconfig.json similarity index 100% rename from packages-ts/gauntlet-starknet-oz-erc20/tsconfig.json rename to packages-ts/gauntlet-starknet-oz/tsconfig.json diff --git a/packages-ts/gauntlet-starknet-starkgate/LICENSE b/packages-ts/gauntlet-starknet-starkgate/LICENSE new file mode 100644 index 000000000..1ad4f08b3 --- /dev/null +++ b/packages-ts/gauntlet-starknet-starkgate/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2022 SmartContract ChainLink, Ltd. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages-ts/gauntlet-starknet-starkgate/README.md b/packages-ts/gauntlet-starknet-starkgate/README.md new file mode 100644 index 000000000..b5a11e23b --- /dev/null +++ b/packages-ts/gauntlet-starknet-starkgate/README.md @@ -0,0 +1,28 @@ +# Gauntlet Starknet Commands for Starkgate Contracts + +## ERC20 + +### Deploy the contract: + +```bash +yarn gauntlet starkgate_erc20:deploy --network= --name= --symbol= --decimals= "--minter=" +# --minter is optional. If not provided, your default account contract will be used as minter +``` + +If you want to deploy a LINK contract, just include the `--link` flag: + +```bash +yarn gauntlet starkgate_erc20:deploy --network=testnet --link +``` + +### Mint + +```bash +yarn gauntlet starkgate_erc20:mint --network= --recipient= --amount= +``` + +### Transfer + +```bash +yarn gauntlet starkgate_erc20:transfer --network= --recipient= --amount= +``` diff --git a/packages-ts/gauntlet-starknet-starkgate/package.json b/packages-ts/gauntlet-starknet-starkgate/package.json new file mode 100644 index 000000000..a15f7cea0 --- /dev/null +++ b/packages-ts/gauntlet-starknet-starkgate/package.json @@ -0,0 +1,32 @@ +{ + "name": "@chainlink/gauntlet-starknet-starkgate", + "version": "0.0.1", + "description": "Gauntlet Starknet Starkgate contracts", + "keywords": [ + "typescript", + "cli" + ], + "main": "./dist/index.js", + "types": "dist/index.d.ts", + "files": [ + "dist/**/*", + "!dist/**/*.test.js" + ], + "scripts": { + "gauntlet": "ts-node ./src/index.ts", + "lint": "tsc", + "test": "SKIP_PROMPTS=true jest --runInBand", + "test:coverage": "yarn test --collectCoverage", + "test:ci": "yarn test --ci", + "lint:format": "yarn prettier --check ./src", + "format": "yarn prettier --write ./src", + "clean": "rm -rf ./dist/ ./bin/", + "build": "yarn clean && tsc -b", + "bundle": "yarn build && pkg ." + }, + "dependencies": { + "@chainlink/gauntlet-core": "0.3.0", + "@chainlink/gauntlet-starknet": "*", + "starknet": "^3.11.0" + } +} diff --git a/packages-ts/gauntlet-starknet-oz-erc20/src/commands/index.ts b/packages-ts/gauntlet-starknet-starkgate/src/commands/index.ts similarity index 100% rename from packages-ts/gauntlet-starknet-oz-erc20/src/commands/index.ts rename to packages-ts/gauntlet-starknet-starkgate/src/commands/index.ts diff --git a/packages-ts/gauntlet-starknet-oz-erc20/src/commands/token/deploy.ts b/packages-ts/gauntlet-starknet-starkgate/src/commands/token/deploy.ts similarity index 79% rename from packages-ts/gauntlet-starknet-oz-erc20/src/commands/token/deploy.ts rename to packages-ts/gauntlet-starknet-starkgate/src/commands/token/deploy.ts index 437d85603..f13e589a8 100644 --- a/packages-ts/gauntlet-starknet-oz-erc20/src/commands/token/deploy.ts +++ b/packages-ts/gauntlet-starknet-starkgate/src/commands/token/deploy.ts @@ -15,19 +15,10 @@ type UserInput = { name: string symbol: string decimals: string - initialSupply: string - recipient?: string - owner?: string + minter?: string } -type ContractInput = [ - name: string, - symbol: string, - decimals: string, - initial_supply: string, - recipient: string, - owner: string, -] +type ContractInput = [name: string, symbol: string, decimals: string, minter: string] const makeUserInput = async (flags, args): Promise => { if (flags.input) return flags.input as UserInput @@ -37,7 +28,6 @@ const makeUserInput = async (flags, args): Promise => { name: 'Chainlink LINK Token', symbol: 'LINK', decimals: '18', - initialSupply: '10000000', } } @@ -45,9 +35,7 @@ const makeUserInput = async (flags, args): Promise => { name: flags.name, symbol: flags.symbol, decimals: flags.decimals, - initialSupply: flags.initialSupply, - recipient: flags.recipient, - owner: flags.owner, + minter: flags.minter, } } @@ -57,14 +45,11 @@ const makeContractInput = async (input: UserInput, context: ExecutionContext): P shortString.encodeShortString(input.name), shortString.encodeShortString(input.symbol), input.decimals, - new BN(input.initialSupply).toString(), - input.recipient || defaultWallet, - input.owner || defaultWallet, + input.minter || defaultWallet, ] } const validate: Validation = async (input) => { - // todo: validate every fiels exists return true } diff --git a/packages-ts/gauntlet-starknet-starkgate/src/commands/token/index.ts b/packages-ts/gauntlet-starknet-starkgate/src/commands/token/index.ts new file mode 100644 index 000000000..96b3b592e --- /dev/null +++ b/packages-ts/gauntlet-starknet-starkgate/src/commands/token/index.ts @@ -0,0 +1,5 @@ +import Deploy from './deploy' +import Mint from './mint' +import Transfer from './transfer' + +export default [Deploy, Mint, Transfer] diff --git a/packages-ts/gauntlet-starknet-starkgate/src/commands/token/mint.ts b/packages-ts/gauntlet-starknet-starkgate/src/commands/token/mint.ts new file mode 100644 index 000000000..ae37e2157 --- /dev/null +++ b/packages-ts/gauntlet-starknet-starkgate/src/commands/token/mint.ts @@ -0,0 +1,56 @@ +import { BeforeExecute, ExecuteCommandConfig, makeExecuteCommand, Validation } from '@chainlink/gauntlet-starknet' +import { Uint256 } from 'starknet/dist/utils/uint256' +import { bnToUint256 } from 'starknet/dist/utils/uint256' +import { CATEGORIES } from '../../lib/categories' +import { contractLoader } from '../../lib/contracts' + +type UserInput = { + recipient: string + amount: string +} + +type ContractInput = [recipient: string, amount: Uint256] + +const makeUserInput = async (flags, args): Promise => { + if (flags.input) return flags.input as UserInput + + return { + recipient: flags.recipient, + amount: flags.amount, + } +} + +const makeContractInput = async (input: UserInput): Promise => { + return [input.recipient, bnToUint256(input.amount)] +} + +const validate: Validation = async (input) => { + return true +} + +const beforeExecute: BeforeExecute = (context, input, deps) => async () => { + deps.logger.info(`About to mint an ERC20 Token Contract with the following details: + ${input.contract} + `) +} + +const commandConfig: ExecuteCommandConfig = { + ux: { + category: CATEGORIES.TOKEN, + function: 'mint', + examples: [ + `${CATEGORIES.TOKEN}:mint --network= --link`, + `${CATEGORIES.TOKEN}:mint --network= --link`, + ], + }, + internalFunction: 'permissionedMint', + makeUserInput, + makeContractInput, + validations: [validate], + loadContract: contractLoader, + hooks: { + beforeExecute, + }, +} + +export default makeExecuteCommand(commandConfig) diff --git a/packages-ts/gauntlet-starknet-starkgate/src/commands/token/transfer.ts b/packages-ts/gauntlet-starknet-starkgate/src/commands/token/transfer.ts new file mode 100644 index 000000000..3819b95e8 --- /dev/null +++ b/packages-ts/gauntlet-starknet-starkgate/src/commands/token/transfer.ts @@ -0,0 +1,64 @@ +import { + BeforeExecute, + ExecuteCommandConfig, + makeExecuteCommand, + Validation, + isValidAddress, +} from '@chainlink/gauntlet-starknet' +import { Uint256 } from 'starknet/dist/utils/uint256' +import { bnToUint256 } from 'starknet/dist/utils/uint256' +import { CATEGORIES } from '../../lib/categories' +import { contractLoader } from '../../lib/contracts' + +type UserInput = { + recipient: string + amount: string +} + +type ContractInput = [recipient: string, amount: Uint256] + +const makeUserInput = async (flags, args): Promise => { + if (flags.input) return flags.input as UserInput + + return { + recipient: flags.recipient, + amount: flags.amount, + } +} + +const makeContractInput = async (input: UserInput): Promise => { + return [input.recipient, bnToUint256(input.amount)] +} + +const validateRecipient: Validation = async (input) => { + if (!isValidAddress(input.recipient)) throw new Error(`Invalid recipient address: ${input.recipient}`) + return true +} + +const validateAmount: Validation = async (input) => { + if (isNaN(Number(input.amount))) throw new Error(`Invalid amount: ${input.amount}`) + return true +} + +const beforeExecute: BeforeExecute = (context, input, deps) => async () => { + deps.logger.info(`About to tranfer ${input.user.amount} ERC20 tokens to ${input.user.recipient}`) +} + +const commandConfig: ExecuteCommandConfig = { + ux: { + category: CATEGORIES.TOKEN, + function: 'transfer', + examples: [ + `${CATEGORIES.TOKEN}:transfer --network= --recipient= --amount= `, + ], + }, + makeUserInput, + makeContractInput, + validations: [validateRecipient, validateAmount], + loadContract: contractLoader, + hooks: { + beforeExecute, + }, +} + +export default makeExecuteCommand(commandConfig) diff --git a/packages-ts/gauntlet-starknet-starkgate/src/index.ts b/packages-ts/gauntlet-starknet-starkgate/src/index.ts new file mode 100644 index 000000000..1b382fcdf --- /dev/null +++ b/packages-ts/gauntlet-starknet-starkgate/src/index.ts @@ -0,0 +1,36 @@ +import { logger, prompt } from '@chainlink/gauntlet-core/dist/utils' +import { + ExecuteCommandInstance, + CommandCtor, + makeWallet, + makeProvider, + Dependencies, + Env, +} from '@chainlink/gauntlet-starknet' + +import Commands from './commands' + +const registerExecuteCommand = ( + registerCommand: (deps: Dependencies) => CommandCtor>, +) => { + const deps: Dependencies = { + logger: logger, + prompt: prompt, + makeEnv: (flags) => { + const env: Env = { + providerUrl: process.env.NODE_URL || 'https://alpha4.starknet.io', + pk: process.env.PRIVATE_KEY, + account: process.env.ACCOUNT, + } + return env + }, + makeProvider: makeProvider, + makeWallet: makeWallet, + } + return registerCommand(deps) +} + +const registeredCommands = Commands.map(registerExecuteCommand) + +export { Commands } +export default [...registeredCommands] diff --git a/packages-ts/gauntlet-starknet-oz-erc20/src/lib/categories.ts b/packages-ts/gauntlet-starknet-starkgate/src/lib/categories.ts similarity index 100% rename from packages-ts/gauntlet-starknet-oz-erc20/src/lib/categories.ts rename to packages-ts/gauntlet-starknet-starkgate/src/lib/categories.ts diff --git a/packages-ts/gauntlet-starknet-oz-erc20/src/lib/contracts.ts b/packages-ts/gauntlet-starknet-starkgate/src/lib/contracts.ts similarity index 92% rename from packages-ts/gauntlet-starknet-oz-erc20/src/lib/contracts.ts rename to packages-ts/gauntlet-starknet-starkgate/src/lib/contracts.ts index 595bc672e..ea584f3ac 100644 --- a/packages-ts/gauntlet-starknet-oz-erc20/src/lib/contracts.ts +++ b/packages-ts/gauntlet-starknet-starkgate/src/lib/contracts.ts @@ -2,7 +2,7 @@ import fs from 'fs' import { CompiledContract, json } from 'starknet' export enum CONTRACT_LIST { - TOKEN = 'oz_erc20', + TOKEN = 'starkgate_erc20', } export const loadContract = (name: CONTRACT_LIST): CompiledContract => { diff --git a/packages-ts/gauntlet-starknet-starkgate/tsconfig.json b/packages-ts/gauntlet-starknet-starkgate/tsconfig.json new file mode 100644 index 000000000..2c84c1fcb --- /dev/null +++ b/packages-ts/gauntlet-starknet-starkgate/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "dist", + "rootDir": "src" + }, + "include": ["src/**/*"], + "exclude": ["dist", "**/*.spec.ts", "**/*.test.ts"] +} diff --git a/packages-ts/gauntlet-starknet/src/commands/base/executeCommand.ts b/packages-ts/gauntlet-starknet/src/commands/base/executeCommand.ts index cc21286cf..699928f0c 100644 --- a/packages-ts/gauntlet-starknet/src/commands/base/executeCommand.ts +++ b/packages-ts/gauntlet-starknet/src/commands/base/executeCommand.ts @@ -38,6 +38,7 @@ export interface ExecuteCommandConfig { beforeExecute?: BeforeExecute afterExecute?: AfterExecute } + internalFunction?: string makeUserInput: (flags, args) => Promise makeContractInput: (userInput: UI, context: ExecutionContext) => Promise validations: Validation[] @@ -150,7 +151,10 @@ export const makeExecuteCommand = (config: ExecuteCommandConfig) // TODO: This will be required for Multisig makeMessage = async (): Promise => { const contract = new Contract(this.contract.abi, this.contractAddress, this.provider.provider) - const invocation = await contract.populate(config.ux.function, this.input.contract as any) + const invocation = await contract.populate( + config.internalFunction || config.ux.function, + this.input.contract as any, + ) return [invocation] } @@ -158,6 +162,7 @@ export const makeExecuteCommand = (config: ExecuteCommandConfig) deployContract = async (): Promise => { deps.logger.info(`Deploying contract ${config.ux.category}`) await deps.prompt('Continue?') + deps.logger.loading(`Sending transaction...`) const tx = await this.provider.deployContract(this.contract, this.input.contract, false) deps.logger.loading(`Waiting for tx confirmation at ${tx.hash}...`) @@ -172,6 +177,8 @@ export const makeExecuteCommand = (config: ExecuteCommandConfig) executeWithSigner = async (): Promise => { const messages = await this.makeMessage() + await deps.prompt(`Continue?`) + deps.logger.loading(`Signing and sending transaction...`) const tx = await this.provider.signAndSend(this.account, this.wallet, messages) deps.logger.loading(`Waiting for tx confirmation at ${tx.hash}...`) const response = await tx.wait() @@ -185,7 +192,9 @@ export const makeExecuteCommand = (config: ExecuteCommandConfig) executeWithoutSigner = async (): Promise => { const contract = new Contract(this.contract.abi, this.contractAddress, this.provider.provider) - const tx = await contract[config.ux.function](...(this.input.contract as any)) + await deps.prompt(`Continue?`) + deps.logger.loading(`Sending transaction...`) + const tx = await contract[config.internalFunction || config.ux.function](...(this.input.contract as any)) const response = wrapResponse(this.provider, tx, this.contractAddress) deps.logger.loading(`Waiting for tx confirmation at ${response.hash}...`) await response.wait() diff --git a/packages-ts/gauntlet-starknet/src/index.ts b/packages-ts/gauntlet-starknet/src/index.ts index 422f797fb..ff88b097f 100644 --- a/packages-ts/gauntlet-starknet/src/index.ts +++ b/packages-ts/gauntlet-starknet/src/index.ts @@ -3,3 +3,4 @@ export * from './dependencies' export * from './provider' export * from './wallet' export * from './events' +export * from './utils' diff --git a/packages-ts/gauntlet-starknet/src/utils/address.ts b/packages-ts/gauntlet-starknet/src/utils/address.ts new file mode 100644 index 000000000..62062f4ab --- /dev/null +++ b/packages-ts/gauntlet-starknet/src/utils/address.ts @@ -0,0 +1,10 @@ +import { validateAndParseAddress } from 'starknet' + +// TODO: This is inconsistent. come back here +export const isValidAddress = (address: string): boolean => { + try { + validateAndParseAddress(address) + return true + } catch (e) {} + return false +} diff --git a/packages-ts/gauntlet-starknet/src/utils/index.ts b/packages-ts/gauntlet-starknet/src/utils/index.ts new file mode 100644 index 000000000..6f5a55683 --- /dev/null +++ b/packages-ts/gauntlet-starknet/src/utils/index.ts @@ -0,0 +1 @@ +export * from './address' diff --git a/tsconfig.json b/tsconfig.json index 59580d45b..154038e5d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,10 +10,13 @@ "path": "./packages-ts/gauntlet-starknet-example" }, { - "path": "./packages-ts/gauntlet-starknet-account" + "path": "./packages-ts/gauntlet-starknet-oz" }, { - "path": "./packages-ts/gauntlet-starknet-oz-erc20" + "path": "./packages-ts/gauntlet-starknet-starkgate" + }, + { + "path": "./packages-ts/gauntlet-starknet-argent" }, { "path": "./packages-ts/gauntlet-starknet-ocr2" From 5c24b48aab548bdc53e4dee0525ca0579f8b29cb Mon Sep 17 00:00:00 2001 From: RodrigoAD <15104916+RodrigoAD@users.noreply.github.com> Date: Thu, 26 May 2022 11:56:50 +0200 Subject: [PATCH 3/4] update docs index --- docs/gauntlet/README.md | 4 +++- packages-ts/gauntlet-starknet-argent/README.md | 4 ++-- packages-ts/gauntlet-starknet-oz/README.md | 2 +- packages-ts/gauntlet-starknet-starkgate/README.md | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/gauntlet/README.md b/docs/gauntlet/README.md index 4d85f55b2..2c0e03871 100644 --- a/docs/gauntlet/README.md +++ b/docs/gauntlet/README.md @@ -6,6 +6,8 @@ - [Basic Setup](./getting_started.md#basic-setup) - [CLI](../../packages-ts/gauntlet-starknet-cli/README.md) - [Example Contract](../../packages-ts/gauntlet-starknet-example/README.md) - - [Account Contract](../../packages-ts/gauntlet-starknet-account/README.md) + - [OZ Contracts](../../packages-ts/gauntlet-starknet-oz/README.md) + - [Starkgate Contracts](../../packages-ts/gauntlet-starknet-starkgate/README.md) + - [Argent Contracts](../../packages-ts/gauntlet-starknet-argent/README.md) - [OCR2 Contracts](../../packages-ts/gauntlet-starknet-ocr2/README.md) - Contribute diff --git a/packages-ts/gauntlet-starknet-argent/README.md b/packages-ts/gauntlet-starknet-argent/README.md index 616a45991..c86409acf 100644 --- a/packages-ts/gauntlet-starknet-argent/README.md +++ b/packages-ts/gauntlet-starknet-argent/README.md @@ -2,7 +2,7 @@ ## Account -Deploy the contract: +### Deploy ``` yarn gauntlet argent_account:deploy --network= @@ -10,7 +10,7 @@ yarn gauntlet argent_account:deploy --network= Note the contract address. The contract is not configured yet. A signer needs to be specified in it: -Initialize the contract: +### Initialize ```bash yarn gauntlet argent_account:initialize --network= diff --git a/packages-ts/gauntlet-starknet-oz/README.md b/packages-ts/gauntlet-starknet-oz/README.md index 8df81009a..5a7399488 100644 --- a/packages-ts/gauntlet-starknet-oz/README.md +++ b/packages-ts/gauntlet-starknet-oz/README.md @@ -2,7 +2,7 @@ ## Account -Run the following command: +### Deploy ```bash yarn gauntlet account:deploy --network= diff --git a/packages-ts/gauntlet-starknet-starkgate/README.md b/packages-ts/gauntlet-starknet-starkgate/README.md index b5a11e23b..a15de628b 100644 --- a/packages-ts/gauntlet-starknet-starkgate/README.md +++ b/packages-ts/gauntlet-starknet-starkgate/README.md @@ -2,7 +2,7 @@ ## ERC20 -### Deploy the contract: +### Deploy the contract ```bash yarn gauntlet starkgate_erc20:deploy --network= --name= --symbol= --decimals= "--minter=" From 068e0a4cd4e312c75ff72273ed02787fca609791 Mon Sep 17 00:00:00 2001 From: RodrigoAD <15104916+RodrigoAD@users.noreply.github.com> Date: Fri, 27 May 2022 16:38:08 +0200 Subject: [PATCH 4/4] remove unnecessary validations --- .../gauntlet-starknet-argent/src/commands/account/deploy.ts | 6 +----- .../src/commands/account/initialize.ts | 6 +----- .../src/commands/token/deploy.ts | 6 +----- .../gauntlet-starknet-starkgate/src/commands/token/mint.ts | 6 +----- 4 files changed, 4 insertions(+), 20 deletions(-) diff --git a/packages-ts/gauntlet-starknet-argent/src/commands/account/deploy.ts b/packages-ts/gauntlet-starknet-argent/src/commands/account/deploy.ts index d78a3f202..b096992b3 100644 --- a/packages-ts/gauntlet-starknet-argent/src/commands/account/deploy.ts +++ b/packages-ts/gauntlet-starknet-argent/src/commands/account/deploy.ts @@ -18,10 +18,6 @@ const makeContractInput = async (input: UserInput, context: ExecutionContext): P return [] } -const validate: Validation = async (input) => { - return true -} - const beforeExecute: BeforeExecute = (context, input, deps) => async () => { deps.logger.info(`About to deploy an Argent Account Contract`) } @@ -34,7 +30,7 @@ const commandConfig: ExecuteCommandConfig = { }, makeUserInput, makeContractInput, - validations: [validate], + validations: [], loadContract: accountContractLoader, hooks: { beforeExecute, diff --git a/packages-ts/gauntlet-starknet-argent/src/commands/account/initialize.ts b/packages-ts/gauntlet-starknet-argent/src/commands/account/initialize.ts index e3c5096d6..278d3d2e1 100644 --- a/packages-ts/gauntlet-starknet-argent/src/commands/account/initialize.ts +++ b/packages-ts/gauntlet-starknet-argent/src/commands/account/initialize.ts @@ -33,10 +33,6 @@ const makeContractInput = async (input: UserInput): Promise => { return [input.publicKey, 0] } -const validate: Validation = async (input) => { - return true -} - const beforeExecute: BeforeExecute = (context, input, deps) => async () => { deps.logger.info(`About to deploy an Account Contract with public key ${input.contract[0]}`) if (input.user.privateKey) { @@ -66,7 +62,7 @@ const commandConfig: ExecuteCommandConfig = { }, makeUserInput, makeContractInput, - validations: [validate], + validations: [], loadContract: accountContractLoader, hooks: { beforeExecute, diff --git a/packages-ts/gauntlet-starknet-starkgate/src/commands/token/deploy.ts b/packages-ts/gauntlet-starknet-starkgate/src/commands/token/deploy.ts index f13e589a8..02a39ea89 100644 --- a/packages-ts/gauntlet-starknet-starkgate/src/commands/token/deploy.ts +++ b/packages-ts/gauntlet-starknet-starkgate/src/commands/token/deploy.ts @@ -49,10 +49,6 @@ const makeContractInput = async (input: UserInput, context: ExecutionContext): P ] } -const validate: Validation = async (input) => { - return true -} - const beforeExecute: BeforeExecute = (context, input, deps) => async () => { deps.logger.info(`About to deploy an ERC20 Token Contract with the following details: ${input.contract} @@ -70,7 +66,7 @@ const commandConfig: ExecuteCommandConfig = { }, makeUserInput, makeContractInput, - validations: [validate], + validations: [], loadContract: contractLoader, hooks: { beforeExecute, diff --git a/packages-ts/gauntlet-starknet-starkgate/src/commands/token/mint.ts b/packages-ts/gauntlet-starknet-starkgate/src/commands/token/mint.ts index ae37e2157..0dbfd84fb 100644 --- a/packages-ts/gauntlet-starknet-starkgate/src/commands/token/mint.ts +++ b/packages-ts/gauntlet-starknet-starkgate/src/commands/token/mint.ts @@ -24,10 +24,6 @@ const makeContractInput = async (input: UserInput): Promise => { return [input.recipient, bnToUint256(input.amount)] } -const validate: Validation = async (input) => { - return true -} - const beforeExecute: BeforeExecute = (context, input, deps) => async () => { deps.logger.info(`About to mint an ERC20 Token Contract with the following details: ${input.contract} @@ -46,7 +42,7 @@ const commandConfig: ExecuteCommandConfig = { internalFunction: 'permissionedMint', makeUserInput, makeContractInput, - validations: [validate], + validations: [], loadContract: contractLoader, hooks: { beforeExecute,