diff --git a/.prettierignore b/.prettierignore index d0b804da..b81d297f 100644 --- a/.prettierignore +++ b/.prettierignore @@ -2,3 +2,4 @@ /dist /coverage + diff --git a/package.json b/package.json index fe15610d..a5887e45 100644 --- a/package.json +++ b/package.json @@ -1,48 +1,48 @@ { - "name": "sei-js", - "version": "1.1.5", - "license": "MIT", - "scripts": { - "build:all": "nx run-many --target=build", - "build:since": "nx affected --target=build", - "lint:all": "nx run-many --target=lint", - "lint:since": "nx affected --target=lint", - "test:all": "nx run-many --target=test", - "test:since": "nx affected --target=test", - "test:coverage": "nx affected:test --all --coverage --skip-nx-cache", - "release": "yarn build:all && changeset publish", - "release:internal": "yarn build:all && yarn changeset && yarn changeset version --snapshot internal && yarn changeset publish --no-git-tag --snapshot --tag internal", - "postrelease": "git push --follow-tags" - }, - "private": true, - "dependencies": { - "@changesets/cli": "^2.26.0" - }, - "devDependencies": { - "@nrwl/eslint-plugin-nx": "15.5.1", - "@nrwl/nx-cloud": "latest", - "@nrwl/workspace": "15.5.1", - "@types/jest": "^29.5.5", - "@types/node": "20.8.2", - "@typescript-eslint/eslint-plugin": "^5.50.0", - "@typescript-eslint/parser": "^5.50.0", - "eslint": "^8.33.0", - "eslint-config-prettier": "8.1.0", - "eslint-plugin-import": "2.26.0", - "eslint-plugin-jsx-a11y": "6.6.1", - "eslint-plugin-prettier": "^4.2.1", - "eslint-plugin-react": "7.31.11", - "eslint-plugin-react-hooks": "4.6.0", - "jest": "29.7.0", - "jest-environment-jsdom": "28.1.1", - "nx": "15.5.1", - "prettier": "^2.6.2", - "rimraf": "^3.0.2", - "ts-jest": "29.1.1", - "ts-node": "10.9.1", - "typescript": "~4.8.4" - }, - "workspaces": [ - "packages/*" - ] + "name": "sei-js", + "version": "1.1.5", + "private": true, + "license": "MIT", + "workspaces": [ + "packages/*" + ], + "scripts": { + "build:all": "nx run-many --target=build", + "build:since": "nx affected --target=build", + "lint:all": "nx run-many --target=lint", + "lint:since": "nx affected --target=lint", + "release": "yarn build:all && changeset publish", + "postrelease": "git push --follow-tags", + "release:internal": "yarn build:all && yarn changeset && yarn changeset version --snapshot internal && yarn changeset publish --no-git-tag --snapshot --tag internal", + "test:all": "nx run-many --target=test", + "test:coverage": "nx affected:test --all --coverage --skip-nx-cache", + "test:since": "nx affected --target=test" + }, + "dependencies": { + "@changesets/cli": "^2.26.0" + }, + "devDependencies": { + "@nrwl/eslint-plugin-nx": "15.5.1", + "@nrwl/nx-cloud": "latest", + "@nrwl/workspace": "15.5.1", + "@types/jest": "^29.5.5", + "@types/node": "20.8.2", + "@typescript-eslint/eslint-plugin": "^5.50.0", + "@typescript-eslint/parser": "^5.50.0", + "eslint": "^8.33.0", + "eslint-config-prettier": "8.1.0", + "eslint-plugin-import": "2.26.0", + "eslint-plugin-jsx-a11y": "6.6.1", + "eslint-plugin-prettier": "^4.2.1", + "eslint-plugin-react": "7.31.11", + "eslint-plugin-react-hooks": "4.6.0", + "jest": "29.7.0", + "jest-environment-jsdom": "28.1.1", + "nx": "15.5.1", + "prettier": "^2.6.2", + "rimraf": "^3.0.2", + "ts-jest": "29.1.1", + "ts-node": "10.9.1", + "typescript": "~4.8.4" + } } diff --git a/packages/core/package.json b/packages/core/package.json index 8e3b93d1..6d19386b 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,33 +1,41 @@ { "name": "@sei-js/core", - "version": "3.1.1", + "version": "0.0.0-internal-20231129052901", + "private": false, "description": "TypeScript library for front end integrations with Sei", + "keywords": [ + "sei", + "javascript", + "typescript" + ], + "homepage": "https://github.com/sei-protocol/sei-js#readme", + "repository": "git@github.com:sei-protocol/sei-js.git", + "license": "MIT", + "sideEffects": false, + "exports": { + ".": { + "import": "./dist/esm/index.js", + "require": "./dist/cjs/index.js", + "browser": { + "import": "./dist/esm/index-browser.js", + "require": "./dist/cjs/index-browser.js" + }, + "types": "./dist/types/index.d.ts" + } + }, "main": "./dist/cjs/index.js", "module": "./dist/esm/index.js", "browser": "./dist/esm/index-browser.js", - "sideEffects": false, "types": "./dist/types/index.d.ts", "scripts": { "prebuild": "rimraf dist", "build": "yarn build:types && yarn build:cjs && yarn build:esm && yarn build:prettier", - "build:types": "tsc --project tsconfig.declarations.json", "build:cjs": "BABEL_ENV=cjs babel src --out-dir dist/cjs --extensions '.js,.jsx,.ts,.tsx' --source-maps --copy-files --no-copy-ignored", "build:esm": "BABEL_ENV=esm babel src --out-dir dist/esm --extensions '.js,.jsx,.ts,.tsx' --source-maps --copy-files --no-copy-ignored", "build:prettier": "prettier --write 'dist/**/*.js'", + "build:types": "tsc --project tsconfig.declarations.json", "test": "jest" }, - "homepage": "https://github.com/sei-protocol/sei-js#readme", - "keywords": [ - "sei", - "javascript", - "typescript" - ], - "repository": "git@github.com:sei-protocol/sei-js.git", - "license": "MIT", - "private": false, - "publishConfig": { - "access": "public" - }, "dependencies": { "@cosmjs/amino": "^0.29.5", "@cosmjs/cosmwasm-stargate": "^0.29.5", @@ -58,15 +66,7 @@ "@types/elliptic": "^6.4.14", "@types/sha.js": "^2.4.1" }, - "exports": { - ".": { - "import": "./dist/esm/index.js", - "require": "./dist/cjs/index.js", - "browser": { - "import": "./dist/esm/index-browser.js", - "require": "./dist/cjs/index-browser.js" - }, - "types": "./dist/types/index.d.ts" - } + "publishConfig": { + "access": "public" } } diff --git a/packages/core/src/lib/index.ts b/packages/core/src/lib/index.ts index 18edc39b..8dcfe7e6 100644 --- a/packages/core/src/lib/index.ts +++ b/packages/core/src/lib/index.ts @@ -1,5 +1,4 @@ export * from './queryClient'; export * from './signingClient'; -export * from './snaps'; export * from './wallet'; export * from './utils'; diff --git a/packages/core/src/lib/snaps/types.ts b/packages/core/src/lib/snaps/types.ts deleted file mode 100644 index 1b4da8a6..00000000 --- a/packages/core/src/lib/snaps/types.ts +++ /dev/null @@ -1,4 +0,0 @@ -export type SignAminoOptions = { - isADR36?: boolean; - enableExtraEntropy?: boolean; -}; diff --git a/packages/core/tsconfig.json b/packages/core/tsconfig.json index 267c6859..b66fa8f4 100644 --- a/packages/core/tsconfig.json +++ b/packages/core/tsconfig.json @@ -1,24 +1,16 @@ { - "compilerOptions": { - "target": "es6", - "module": "es6", - "declaration": true, - "outDir": "./dist/types", - "strict": true, - "moduleResolution": "node", - "allowSyntheticDefaultImports": true, - "skipLibCheck": true, - "noImplicitAny": false, - "lib": [ - "ES6", - "DOM" - ] - }, - "include": ["src"], - "exclude": [ - "node_modules", - "**/*.spec.ts", - "**/*.test.ts", - "**/__tests__/**/*" - ] + "compilerOptions": { + "target": "es6", + "module": "es6", + "declaration": true, + "outDir": "./dist/types", + "strict": true, + "moduleResolution": "node", + "allowSyntheticDefaultImports": true, + "skipLibCheck": true, + "noImplicitAny": false, + "lib": ["ES6", "DOM"] + }, + "include": ["src"], + "exclude": ["node_modules", "**/*.spec.ts", "**/*.test.ts", "**/__tests__/**/*"] } diff --git a/packages/metamask-snap/.babelrc.js b/packages/metamask-snap/.babelrc.js new file mode 100644 index 00000000..34a00f68 --- /dev/null +++ b/packages/metamask-snap/.babelrc.js @@ -0,0 +1,25 @@ +module.exports = (api) => { + const babelEnv = process.env.BABEL_ENV || 'esm'; + + api.cache(() => babelEnv); + + const isESM = babelEnv === 'esm'; + + const commonjsPresets = [ + [ + '@babel/preset-env', + { + modules: 'commonjs' + } + ], + '@babel/preset-typescript' + ]; + + const esmPresets = ['@babel/preset-env', '@babel/preset-typescript']; + + return { + presets: isESM ? esmPresets : commonjsPresets, + plugins: ['@babel/plugin-transform-runtime'], + ignore: ['**/*.spec.ts', '**/*.spec.tsx', '**/*.spec.js', '**/*.spec.jsx', '**/__tests__/**/*', '**/__mocks__/**/*'] + }; +}; diff --git a/packages/metamask-snap/.eslintignore b/packages/metamask-snap/.eslintignore index 76add878..82d01192 100644 --- a/packages/metamask-snap/.eslintignore +++ b/packages/metamask-snap/.eslintignore @@ -1,2 +1,5 @@ node_modules -dist \ No newline at end of file +snap +lib + +**/tests/** diff --git a/packages/metamask-snap/.eslintrc.json b/packages/metamask-snap/.eslintrc.json index 5e48028f..31e1a82f 100644 --- a/packages/metamask-snap/.eslintrc.json +++ b/packages/metamask-snap/.eslintrc.json @@ -1,9 +1,9 @@ { - "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"], - "parser": "@typescript-eslint/parser", - "plugins": ["@typescript-eslint"], - "root": true, - "rules": { - "no-case-declarations": "off" - } + "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"], + "parser": "@typescript-eslint/parser", + "plugins": ["@typescript-eslint"], + "root": true, + "rules": { + "no-case-declarations": "off" + } } diff --git a/packages/metamask-snap/jest.config.lib.js b/packages/metamask-snap/jest.config.lib.js new file mode 100644 index 00000000..3911b2a5 --- /dev/null +++ b/packages/metamask-snap/jest.config.lib.js @@ -0,0 +1,6 @@ +/** @type {import('ts-jest').JestConfigWithTsJest} */ +module.exports = { + preset: 'ts-jest', + testEnvironment: 'jsdom', + testPathIgnorePatterns: ['node_modules', 'dist', 'src/lib/__tests__/snapWallet.spec.ts'] +}; diff --git a/packages/metamask-snap/jest.config.js b/packages/metamask-snap/jest.config.snap.js similarity index 50% rename from packages/metamask-snap/jest.config.js rename to packages/metamask-snap/jest.config.snap.js index 8e1b2540..6dc66dff 100644 --- a/packages/metamask-snap/jest.config.js +++ b/packages/metamask-snap/jest.config.snap.js @@ -3,5 +3,7 @@ module.exports = { preset: '@metamask/snaps-jest', transform: { '^.+\\.(t|j)sx?$': 'ts-jest' - } + }, + testPathIncludePatterns: ['src/lib/tests/snapWallet.spec.ts'], + testPathIgnorePatterns: ['node_modules', 'dist'] }; diff --git a/packages/metamask-snap/package.json b/packages/metamask-snap/package.json index 73afc027..97ec9968 100644 --- a/packages/metamask-snap/package.json +++ b/packages/metamask-snap/package.json @@ -1,74 +1,96 @@ { - "name": "@sei-js/metamask-snap", - "version": "3.1.1", - "description": "A MetaMask snap for the SEI blockchain", - "repository": { - "type": "git", - "url": "https://github.com/MetaMask/template-snap-monorepo.git" - }, - "license": "(MIT-0 OR Apache-2.0)", - "main": "./dist/bundle.js", - "files": [ - "dist/", - "images/", - "snap.manifest.json" - ], - "scripts": { - "build": "mm-snap build", - "build:clean": "yarn clean && yarn build", - "clean": "rimraf dist", - "lint": "yarn lint:eslint && yarn lint:misc --check", - "lint:eslint": "eslint . --cache --ext js,ts", - "lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write", - "lint:misc": "prettier '**/*.json' '**/*.md' '!CHANGELOG.md' --ignore-path .gitignore", - "serve": "mm-snap serve", - "start": "mm-snap watch", - "test": "jest" - }, - "dependencies": { - "@metamask/snaps-types": "^3.1.0", - "@metamask/snaps-ui": "^3.1.0", - "buffer": "^6.0.3", - "@sei-js/core": "0.0.0-internal-20231128235445" - }, - "devDependencies": { - "@cosmjs/crypto": "^0.31.3", - "@cosmjs/proto-signing": "^0.31.3", - "@cosmjs/stargate": "^0.31.3", - "@jest/globals": "^29.5.0", - "@lavamoat/allow-scripts": "^3.0.0", - "@metamask/auto-changelog": "^3.4.3", - "@metamask/eslint-config": "^12.2.0", - "@metamask/eslint-config-jest": "^12.1.0", - "@metamask/eslint-config-nodejs": "^12.1.0", - "@metamask/eslint-config-typescript": "^12.1.0", - "@metamask/key-tree": "^9.0.0", - "@metamask/snaps-cli": "^3.0.1", - "@metamask/snaps-jest": "^3.1.0", - "@metamask/utils": "^8.2.1", - "@typescript-eslint/eslint-plugin": "^5.33.0", - "@typescript-eslint/parser": "^5.33.0", - "eslint": "^8.21.0", - "eslint-config-prettier": "^8.1.0", - "eslint-plugin-import": "^2.26.0", - "eslint-plugin-jest": "^26.8.2", - "eslint-plugin-jsdoc": "^39.2.9", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-prettier": "^4.2.1", - "jest": "^29.5.0", - "prettier": "^2.2.1", - "prettier-plugin-packagejson": "^2.2.11", - "rimraf": "^3.0.2", - "through2": "^4.0.2", - "ts-jest": "^29.1.0", - "typescript": "^4.7.4" - }, - "packageManager": "yarn@1.22.21", - "engines": { - "node": ">=16.20.2" - }, - "publishConfig": { - "access": "public", - "registry": "https://registry.npmjs.org/" - } + "name": "@sei-js/metamask-snap", + "version": "0.0.0-internal-20231129060458", + "description": "A MetaMask snap for the SEI blockchain", + "repository": { + "type": "git", + "url": "https://github.com/MetaMask/template-snap-monorepo.git" + }, + "license": "MIT", + "exports": { + ".": { + "import": "./lib/esm/index.js", + "require": "./lib/cjs/index.js", + "browser": { + "import": "./lib/esm/index.js", + "require": "./lib/cjs/index.js" + }, + "types": "./lib/types/index.d.ts" + } + }, + "main": "./lib/esm/index.js", + "module": "./lib/esm/index.js", + "browser": "./lib/esm/index.js", + "types": "./lib/types/index.d.ts", + "files": [ + "snap/", + "lib/", + "images/", + "snap.manifest.json" + ], + "scripts": { + "prebuild": "yarn clean", + "build": "yarn build:snap && yarn build:types && yarn build:cjs && yarn build:esm && yarn build:prettier", + "build:snap": "mm-snap build", + "build:types": "tsc --project tsconfig.declarations.json", + "build:cjs": "BABEL_ENV=cjs babel src/lib --out-dir dist/lib/cjs --extensions '.js,.jsx,.ts,.tsx' --source-maps --copy-files --no-copy-ignored", + "build:esm": "BABEL_ENV=esm babel src/lib --out-dir dist/lib/esm --extensions '.js,.jsx,.ts,.tsx' --source-maps --copy-files --no-copy-ignored", + "build:prettier": "prettier --write 'dist/**/*.js'", + "build:clean": "yarn clean && yarn build", + "clean": "rimraf dist", + "lint": "yarn lint:eslint", + "lint:eslint": "eslint . --cache --ext js,ts", + "lint:fix": "yarn lint:eslint --fix", + "serve": "mm-snap serve", + "start": "mm-snap watch", + "test": "yarn test:lib && yarn test:snap", + "test:lib": "jest --config ./jest.config.lib.js", + "test:snap": "jest --config ./jest.config.snap.js" + }, + "dependencies": { + "@metamask/snaps-types": "^3.1.0", + "@metamask/snaps-ui": "^3.1.0", + "@sei-js/core": "^0.0.0-internal-20231129052901", + "buffer": "^6.0.3" + }, + "devDependencies": { + "@cosmjs/crypto": "^0.31.3", + "@cosmjs/proto-signing": "^0.31.3", + "@cosmjs/stargate": "^0.31.3", + "@jest/globals": "^29.5.0", + "@lavamoat/allow-scripts": "^3.0.0", + "@metamask/auto-changelog": "^3.4.3", + "@metamask/eslint-config": "^12.2.0", + "@metamask/eslint-config-jest": "^12.1.0", + "@metamask/eslint-config-nodejs": "^12.1.0", + "@metamask/eslint-config-typescript": "^12.1.0", + "@metamask/key-tree": "^9.0.0", + "@metamask/snaps-cli": "^3.0.1", + "@metamask/snaps-jest": "^3.1.0", + "@metamask/utils": "^8.2.1", + "@typescript-eslint/eslint-plugin": "^5.33.0", + "@typescript-eslint/parser": "^5.33.0", + "eslint": "^8.21.0", + "eslint-config-prettier": "^8.1.0", + "eslint-plugin-import": "^2.26.0", + "eslint-plugin-jest": "^26.8.2", + "eslint-plugin-jsdoc": "^39.2.9", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-prettier": "^4.2.1", + "jest": "^29.5.0", + "prettier": "^2.2.1", + "prettier-plugin-packagejson": "^2.2.11", + "rimraf": "^3.0.2", + "through2": "^4.0.2", + "ts-jest": "^29.1.0", + "typescript": "^4.7.4" + }, + "packageManager": "yarn@1.22.21", + "engines": { + "node": ">=16.20.2" + }, + "publishConfig": { + "access": "public", + "registry": "https://registry.npmjs.org/" + } } diff --git a/packages/metamask-snap/snap.config.ts b/packages/metamask-snap/snap.config.ts index 204bae11..7d94244d 100644 --- a/packages/metamask-snap/snap.config.ts +++ b/packages/metamask-snap/snap.config.ts @@ -3,7 +3,13 @@ import type { SnapConfig } from '@metamask/snaps-cli'; const config: SnapConfig = { bundler: 'webpack', - input: resolve(__dirname, 'src/index.ts'), + input: resolve(__dirname, 'src/snap/index.ts'), + output: { + path: resolve(__dirname, 'dist/snap'), + filename: 'bundle.js', + clean: true, + minimize: true + }, server: { port: 8080 }, diff --git a/packages/metamask-snap/snap.manifest.json b/packages/metamask-snap/snap.manifest.json index 2778c0c1..e27752e8 100644 --- a/packages/metamask-snap/snap.manifest.json +++ b/packages/metamask-snap/snap.manifest.json @@ -1,5 +1,5 @@ { - "version": "0.0.0-internal-20231128220333", + "version": "0.0.0-internal-20231129060458", "description": "A Metamask snap for Sei built with TypeScript", "proposedName": "Sei", "repository": { @@ -7,10 +7,10 @@ "url": "https://github.com/MetaMask/template-snap-monorepo.git" }, "source": { - "shasum": "DdfH5WEL+Dc+cFE1Rwh79pjBnGhSJ8ij2P/dccQgC24=", + "shasum": "jA2Z9ggTJaShT3C1lJQ6GXx+yOLKN03bOQhBc3Y3fUY=", "location": { "npm": { - "filePath": "dist/bundle.js", + "filePath": "dist/snap/bundle.js", "iconPath": "images/icon.svg", "packageName": "@sei-js/metamask-snap", "registry": "https://registry.npmjs.org/" diff --git a/packages/core/src/lib/snaps/__tests__/snapWallet.spec.ts b/packages/metamask-snap/src/lib/__tests__/snapWallet.spec.ts similarity index 100% rename from packages/core/src/lib/snaps/__tests__/snapWallet.spec.ts rename to packages/metamask-snap/src/lib/__tests__/snapWallet.spec.ts diff --git a/packages/core/src/lib/snaps/config.ts b/packages/metamask-snap/src/lib/config.ts similarity index 100% rename from packages/core/src/lib/snaps/config.ts rename to packages/metamask-snap/src/lib/config.ts diff --git a/packages/core/src/lib/snaps/cosmjs.ts b/packages/metamask-snap/src/lib/cosmjs.ts similarity index 92% rename from packages/core/src/lib/snaps/cosmjs.ts rename to packages/metamask-snap/src/lib/cosmjs.ts index bd0a2d40..86084746 100644 --- a/packages/core/src/lib/snaps/cosmjs.ts +++ b/packages/metamask-snap/src/lib/cosmjs.ts @@ -4,16 +4,9 @@ import { DirectSignResponse, OfflineDirectSigner } from '@cosmjs/proto-signing'; import Long from 'long'; import { MM_SNAP_ORIGIN } from './config'; import { SignAminoOptions } from './types'; -import { makeADR36AminoSignDoc } from '../utils'; -import { MetaMaskInpageProvider } from '@metamask/providers'; +import { makeADR36AminoSignDoc } from '@sei-js/core'; import { getWallet } from './snapWallet'; -declare global { - interface Window { - ethereum: MetaMaskInpageProvider & { providers: any[]; detected: any[]; setProvider: (provider: MetaMaskInpageProvider) => void }; - } -} - export const sendReqToSnap = async (method: string, params: any): Promise => { return window.ethereum.request({ method: 'wallet_invokeSnap', diff --git a/packages/core/src/lib/snaps/index.ts b/packages/metamask-snap/src/lib/index.ts similarity index 100% rename from packages/core/src/lib/snaps/index.ts rename to packages/metamask-snap/src/lib/index.ts diff --git a/packages/core/src/lib/snaps/snapWallet.ts b/packages/metamask-snap/src/lib/snapWallet.ts similarity index 95% rename from packages/core/src/lib/snaps/snapWallet.ts rename to packages/metamask-snap/src/lib/snapWallet.ts index 03f17786..0a90e410 100644 --- a/packages/core/src/lib/snaps/snapWallet.ts +++ b/packages/metamask-snap/src/lib/snapWallet.ts @@ -4,9 +4,8 @@ import { SignDoc } from 'cosmjs-types/cosmos/tx/v1beta1/tx'; import { BIP44Node } from '@metamask/key-tree'; import { AccountData, encodeSecp256k1Signature, StdSignDoc } from '@cosmjs/amino'; import { Buffer } from 'buffer'; -import { compressedPubKeyToAddress, serializeAminoSignDoc, serializeDirectSignDoc } from '../utils'; +import { compressedPubKeyToAddress, serializeAminoSignDoc, serializeDirectSignDoc, SeiWallet } from '@sei-js/core'; import { CosmJSOfflineSigner, sendReqToSnap } from './cosmjs'; -import { SeiWallet } from '../wallet'; import { MM_SNAP_ORIGIN } from './config'; export class SnapWallet { @@ -78,7 +77,7 @@ export class SnapWallet { } } -export async function getWallet(account_index: number = 0): Promise { +export async function getWallet(account_index = 0): Promise { const account: BIP44Node = await sendReqToSnap('getPrivateKey', { account_index }); if (account.privateKey) { @@ -105,7 +104,9 @@ export const experimental_SEI_METAMASK_SNAP: SeiWallet = { }); } }, - disconnect: async (_: string) => {}, + disconnect: async (_: string) => { + throw new Error('Not implemented'); + }, getOfflineSigner: async (chainId) => { return new CosmJSOfflineSigner(chainId); }, diff --git a/packages/metamask-snap/src/lib/types.ts b/packages/metamask-snap/src/lib/types.ts new file mode 100644 index 00000000..97f1f96b --- /dev/null +++ b/packages/metamask-snap/src/lib/types.ts @@ -0,0 +1,16 @@ +import { MetaMaskInpageProvider } from '@metamask/providers'; + +declare global { + interface Window { + ethereum: MetaMaskInpageProvider & { + providers: MetaMaskInpageProvider[]; + detected: MetaMaskInpageProvider[]; + setProvider: (provider: MetaMaskInpageProvider) => void; + }; + } +} + +export type SignAminoOptions = { + isADR36?: boolean; + enableExtraEntropy?: boolean; +}; diff --git a/packages/metamask-snap/src/api.ts b/packages/metamask-snap/src/snap/api.ts similarity index 100% rename from packages/metamask-snap/src/api.ts rename to packages/metamask-snap/src/snap/api.ts diff --git a/packages/metamask-snap/src/index.ts b/packages/metamask-snap/src/snap/index.ts similarity index 100% rename from packages/metamask-snap/src/index.ts rename to packages/metamask-snap/src/snap/index.ts diff --git a/packages/metamask-snap/src/tests/ui.spec.ts b/packages/metamask-snap/src/snap/tests/ui.spec.ts similarity index 100% rename from packages/metamask-snap/src/tests/ui.spec.ts rename to packages/metamask-snap/src/snap/tests/ui.spec.ts diff --git a/packages/metamask-snap/src/tests/utils.spec.ts b/packages/metamask-snap/src/snap/tests/utils.spec.ts similarity index 100% rename from packages/metamask-snap/src/tests/utils.spec.ts rename to packages/metamask-snap/src/snap/tests/utils.spec.ts diff --git a/packages/metamask-snap/src/types.ts b/packages/metamask-snap/src/snap/types.ts similarity index 82% rename from packages/metamask-snap/src/types.ts rename to packages/metamask-snap/src/snap/types.ts index e46290e2..ddc7f6c3 100644 --- a/packages/metamask-snap/src/types.ts +++ b/packages/metamask-snap/src/snap/types.ts @@ -5,7 +5,11 @@ import { MetaMaskInpageProvider } from '@metamask/providers'; declare global { interface Window { - ethereum: MetaMaskInpageProvider & { providers: any[]; detected: any[]; setProvider: (provider: MetaMaskInpageProvider) => void }; + ethereum: MetaMaskInpageProvider & { + providers: MetaMaskInpageProvider[]; + detected: MetaMaskInpageProvider[]; + setProvider: (provider: MetaMaskInpageProvider) => void; + }; } } diff --git a/packages/metamask-snap/src/ui.ts b/packages/metamask-snap/src/snap/ui.ts similarity index 100% rename from packages/metamask-snap/src/ui.ts rename to packages/metamask-snap/src/snap/ui.ts diff --git a/packages/metamask-snap/src/utils.ts b/packages/metamask-snap/src/snap/utils.ts similarity index 100% rename from packages/metamask-snap/src/utils.ts rename to packages/metamask-snap/src/snap/utils.ts diff --git a/packages/metamask-snap/tsconfig.declarations.json b/packages/metamask-snap/tsconfig.declarations.json index 27727eea..c56eae0f 100644 --- a/packages/metamask-snap/tsconfig.declarations.json +++ b/packages/metamask-snap/tsconfig.declarations.json @@ -1,14 +1,19 @@ { - "extends": "./tsconfig.json", - "compilerOptions": { - "declaration": true, - "emitDeclarationOnly": true - }, - "include": ["src"], - "exclude": [ - "node_modules", - "**/*.spec.ts", - "**/*.test.ts", - "**/__tests__/**/*" - ] + "compilerOptions": { + "target": "es6", + "module": "es6", + "declaration": true, + "outDir": "./dist/lib/types", + "strict": true, + "moduleResolution": "node", + "allowSyntheticDefaultImports": true, + "skipLibCheck": true, + "noImplicitAny": false, + "lib": ["ES6", "DOM"], + "emitDeclarationOnly": true + }, + "include": [ + "src/lib" + ], + "exclude": ["**/*.spec.ts", "**/*.spec.ts", "**/*.test.ts", "**/__tests__/**/*"] } diff --git a/packages/metamask-snap/tsconfig.json b/packages/metamask-snap/tsconfig.json index 7809eeae..d29bda34 100644 --- a/packages/metamask-snap/tsconfig.json +++ b/packages/metamask-snap/tsconfig.json @@ -1,16 +1,18 @@ { - "compilerOptions": { - "declaration": true, - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "lib": ["DOM", "ES2020"], - "module": "CommonJS", - "moduleResolution": "node", - "useUnknownInCatchVariables": false, - "sourceMap": true, - "strict": true, - "target": "ES2020" - }, - "include": ["src"], - "exclude": ["**/__snapshots__/**", "**/*.test.ts"] + "compilerOptions": { + "declaration": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "lib": ["DOM", "ES2020"], + "module": "CommonJS", + "moduleResolution": "node", + "useUnknownInCatchVariables": false, + "sourceMap": true, + "strict": true, + "target": "ES2020" + }, + "include": ["src"], + "exclude": ["**/__snapshots__/**", "**/*.test.ts", "node_modules", + "src/lib" + ] } diff --git a/packages/proto/tsconfig.json b/packages/proto/tsconfig.json index ec725031..08177688 100644 --- a/packages/proto/tsconfig.json +++ b/packages/proto/tsconfig.json @@ -1,22 +1,16 @@ { - "compilerOptions": { - "target": "es2020", - "module": "es2020", - "declaration": true, - "outDir": "./dist/types", - "allowSyntheticDefaultImports": true, - "skipLibCheck": true, - "noImplicitAny": false, - "esModuleInterop": true, - "moduleResolution": "node", - "lib": [ - "ES2020" - ] - }, - "include": [ - "src/**/*" - ], - "exclude": [ - "node_modules" - ] + "compilerOptions": { + "target": "es2020", + "module": "es2020", + "declaration": true, + "outDir": "./dist/types", + "allowSyntheticDefaultImports": true, + "skipLibCheck": true, + "noImplicitAny": false, + "esModuleInterop": true, + "moduleResolution": "node", + "lib": ["ES2020"] + }, + "include": ["src/**/*"], + "exclude": ["node_modules"] } diff --git a/packages/react/tsconfig.json b/packages/react/tsconfig.json index c5364236..2aa65f41 100644 --- a/packages/react/tsconfig.json +++ b/packages/react/tsconfig.json @@ -1,32 +1,19 @@ { - "compilerOptions": { - "target": "es6", - "module": "es6", - "declaration": true, - "outDir": "./dist/types", - "strict": true, - "allowSyntheticDefaultImports": true, - "skipLibCheck": true, - "noImplicitAny": false, - "esModuleInterop": true, - "moduleResolution": "node", - "lib": [ - "DOM", - "ES6", - "DOM.Iterable", - "ScriptHost", - "ES2016.Array.Include" - ], - "jsx": "react-jsx", - "jsxImportSource": "react" - }, - "include": ["src"], - "exclude": [ - "node_modules", - "**/*.spec.ts", - "**/*.spec.js", - "**/*.test.ts", - "**/*.test.js", - "**/__tests__/**/*" - ] + "compilerOptions": { + "target": "es6", + "module": "es6", + "declaration": true, + "outDir": "./dist/types", + "strict": true, + "allowSyntheticDefaultImports": true, + "skipLibCheck": true, + "noImplicitAny": false, + "esModuleInterop": true, + "moduleResolution": "node", + "lib": ["DOM", "ES6", "DOM.Iterable", "ScriptHost", "ES2016.Array.Include"], + "jsx": "react-jsx", + "jsxImportSource": "react" + }, + "include": ["src"], + "exclude": ["node_modules", "**/*.spec.ts", "**/*.spec.js", "**/*.test.ts", "**/*.test.js", "**/__tests__/**/*"] } diff --git a/project.json b/project.json index 3a54f6ff..9f8eab33 100644 --- a/project.json +++ b/project.json @@ -1,13 +1,13 @@ { - "name": "workspace", - "$schema": "node_modules/nx/schemas/project-schema.json", - "targets": { - "version": { - "executor": "@jscutlery/semver:version", - "options": { - "syncVersions": true, - "preset": "conventional" - } - } - } + "name": "workspace", + "$schema": "node_modules/nx/schemas/project-schema.json", + "targets": { + "version": { + "executor": "@jscutlery/semver:version", + "options": { + "syncVersions": true, + "preset": "conventional" + } + } + } } diff --git a/yarn.lock b/yarn.lock index 15ce8433..c500120f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4964,10 +4964,10 @@ "@noble/hashes" "~1.3.0" "@scure/base" "~1.1.0" -"@sei-js/core@0.0.0-internal-20231128235445": - version "0.0.0-internal-20231128235445" - resolved "https://registry.npmjs.org/@sei-js/core/-/core-0.0.0-internal-20231128235445.tgz#bbc517b0697c3ebdc52f387f7cc91bc5d66350b5" - integrity sha512-5Ia2I7Qy/CsT1jlpMRGtKgt+3uz59eRGPbAI0rtqmd9cdhb/qbBbsByhCyuFv17ldVVP6A3pZBJy+FLtXYK7Cg== +"@sei-js/core@^3.1.1": + version "3.1.1" + resolved "https://registry.npmjs.org/@sei-js/core/-/core-3.1.1.tgz#91de4dcc784eab01734e7411ee0c75bc817799cb" + integrity sha512-0Njp9Id+Yol2c8ZTBqXQE0NFvEQd979WNtPD0JoXQOOqRvipvHBhxSB/yCXXPSA869870NrjSHBUZUtylZBeyw== dependencies: "@cosmjs/amino" "^0.29.5" "@cosmjs/cosmwasm-stargate" "^0.29.5"