Skip to content

Commit

Permalink
- Removed verify arbitrary from snap, moved to SeiWallet creation
Browse files Browse the repository at this point in the history
  • Loading branch information
codebycarson committed Jan 4, 2024
1 parent 43e01bd commit e3c476e
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 103 deletions.
2 changes: 1 addition & 1 deletion packages/metamask-snap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"dependencies": {
"@metamask/snaps-types": "^3.1.0",
"@metamask/snaps-ui": "^3.1.0",
"@sei-js/core": "0.0.0-internal-20240104081628",
"@sei-js/core": "0.0.0-internal-20240104185656",
"buffer": "^6.0.3"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/metamask-snap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/template-snap-monorepo.git"
},
"source": {
"shasum": "lNzA3MPIVYkpwOrvg9HdFZMIWtoY9Dv73mQoafkIGq8=",
"shasum": "Va52pfljmjPtKKPndRZs8/7Dpr049tVBA32yYYuES84=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
9 changes: 1 addition & 8 deletions packages/metamask-snap/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { OnRpcRequestHandler } from '@metamask/snaps-types';
import { SignAminoRequest, SignDirectRequest, VerifyArbitraryRequest } from './types';
import { verifyArbitrary } from '@sei-js/core';
import { SignAminoRequest, SignDirectRequest } from './types';
import Long from 'long';
import { sanitizedUint8Array } from './utils';
import { getAminoPanel, getDirectPanel } from './ui';
Expand Down Expand Up @@ -29,12 +28,6 @@ export const onRpcRequest: OnRpcRequestHandler = async ({ request }) => {
if (!account?.privateKey) return;
const wallet = SnapWallet.create(account.privateKey);
switch (request.method) {
case 'verifyArbitrary':
const { signer, message, signature } = request.params as unknown as VerifyArbitraryRequest;
if (!signer || !message) {
throw new Error('Invalid params');
}
return await verifyArbitrary(signer, message, signature);
case 'signDirect': {
const params = request.params as unknown as SignDirectRequest;

Expand Down
6 changes: 0 additions & 6 deletions packages/metamask-snap/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ export interface SnapRequest {
account_index?: number;
}

export interface VerifyArbitraryRequest extends SnapRequest {
readonly signer: string;
readonly message: string;
readonly signature: StdSignature;
}

export interface SignDirectRequest extends SnapRequest {
readonly signDoc: SignDoc;
readonly signerAddress: string;
Expand Down
15 changes: 5 additions & 10 deletions packages/metamask-snap/test-ui/src/utils/snap.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SeiWallet, CosmJSOfflineSigner, getSnapEthereumProvider, sendReqToSnap } from '@sei-js/core';
import { SeiWallet, CosmJSOfflineSigner, getSnapEthereumProvider, verifyArbitrary } from '@sei-js/core';
import Buffer from 'buffer';

// @ts-ignore
Expand Down Expand Up @@ -37,15 +37,10 @@ export const getMetaMaskSnap = (snapId: string): SeiWallet => {
return offlineSigner.signArbitrary(signer, message, { enableExtraEntropy: true });
},
verifyArbitrary: async (_: string, signingAddress, data, signature) => {
return (await sendReqToSnap(
'verifyArbitrary',
{
signer: signingAddress,
message: data,
signature
},
snapId
)) as unknown as boolean;
if (!signingAddress || !data) {
throw new Error('Invalid params');
}
return await verifyArbitrary(signingAddress, data, signature);
},
walletInfo: {
windowKey: 'ethereum',
Expand Down
86 changes: 9 additions & 77 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3171,14 +3171,14 @@
esquery "^1.4.0"
jsdoc-type-pratt-parser "~3.1.0"

"@eslint-community/eslint-utils@^4.1.2", "@eslint-community/eslint-utils@^4.2.0", "@eslint-community/eslint-utils@^4.4.0":
"@eslint-community/eslint-utils@^4.2.0":
version "4.4.0"
resolved "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz#a23514e8fb9af1269d5f7788aa556798d61c6b59"
integrity sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==
dependencies:
eslint-visitor-keys "^3.3.0"

"@eslint-community/regexpp@^4.4.0", "@eslint-community/regexpp@^4.6.0", "@eslint-community/regexpp@^4.6.1":
"@eslint-community/regexpp@^4.4.0", "@eslint-community/regexpp@^4.6.1":
version "4.10.0"
resolved "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.10.0.tgz#548f6de556857c8bb73bbee70c35dc82a2e74d63"
integrity sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA==
Expand Down Expand Up @@ -4964,10 +4964,10 @@
"@noble/hashes" "~1.3.0"
"@scure/base" "~1.1.0"

"@sei-js/core@0.0.0-internal-20240104081628":
version "0.0.0-internal-20240104081628"
resolved "https://registry.npmjs.org/@sei-js/core/-/core-0.0.0-internal-20240104081628.tgz#33b9a533e3b2e5b5da2ac529e2cd932e3521d2b0"
integrity sha512-7rchnDtrPhaCo4GoEHadO0PEyahyLK7+Tnrs2hI12ZcY7klLs/oIfTJqOhTh05CUyUSEUiLM/sOsq5k2aoDTEA==
"@sei-js/core@^3.1.1":
version "3.1.2"
resolved "https://registry.npmjs.org/@sei-js/core/-/core-3.1.2.tgz#aa806eba3dd7c5b7feb5d28f5db6134c5566e694"
integrity sha512-apaYAvfd8qxBe50BGV7Y5OcsJBHymrSKVMfl/rNn3aYubf7La4L1zuxlBUfcrynKslTqUoFJ5gbhIvDsQ8lP0g==
dependencies:
"@cosmjs/amino" "^0.29.5"
"@cosmjs/cosmwasm-stargate" "^0.29.5"
Expand All @@ -4981,7 +4981,6 @@
"@cosmjs/utils" "^0.29.5"
"@ethersproject/keccak256" "^5.7.0"
"@keplr-wallet/types" "^0.11.41"
"@noble/secp256k1" "1.7.1"
"@sei-js/proto" "^3.1.0"
bech32 "^2.0.0"
buffer "^6.0.3"
Expand Down Expand Up @@ -6994,17 +6993,12 @@ buffers@~0.1.1:
resolved "https://registry.npmjs.org/buffers/-/buffers-0.1.1.tgz#b24579c3bed4d6d396aeee6d9a8ae7f5482ab7bb"
integrity sha512-9q/rDEGSb/Qsvv2qvzIzdluL5k7AaJOTrw23z9reQthrbF7is4CtlT0DXyO1oei2DCp4uojjzQ7igaSHp1kAEQ==

builtin-modules@^3.3.0:
version "3.3.0"
resolved "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz#cae62812b89801e9656336e46223e030386be7b6"
integrity sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==

builtin-status-codes@^3.0.0:
version "3.0.0"
resolved "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8"
integrity sha512-HpGFw18DgFWlncDfjTa2rcQ4W88O1mC8e8yZ2AvQY5KDaktSTwo+KRf6nHK6FRI5FyRyb/5T6+TSxfP7QyGsmQ==

builtins@^5.0.0, builtins@^5.0.1:
builtins@^5.0.0:
version "5.0.1"
resolved "https://registry.npmjs.org/builtins/-/builtins-5.0.1.tgz#87f6db9ab0458be728564fa81d876d8d74552fa9"
integrity sha512-qwVpFEHNfhYJIzNRBvd2C1kyo6jz3ZSMPyyuR47OPdiKWlbYnZNyDWuyR175qDnAJLiCo5fBBqPb3RiXgWlkOQ==
Expand Down Expand Up @@ -8585,11 +8579,6 @@ escodegen@^2.0.0, escodegen@^2.1.0:
optionalDependencies:
source-map "~0.6.1"

eslint-compat-utils@^0.1.2:
version "0.1.2"
resolved "https://registry.npmjs.org/eslint-compat-utils/-/eslint-compat-utils-0.1.2.tgz#f45e3b5ced4c746c127cf724fb074cd4e730d653"
integrity sha512-Jia4JDldWnFNIru1Ehx1H5s9/yxiRHY/TimCuUc0jNexew3cF1gI6CYZil1ociakfWO3rRqFjl1mskBblB3RYg==

[email protected]:
version "8.1.0"
resolved "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.1.0.tgz#4ef1eaf97afe5176e6a75ddfb57c335121abc5a6"
Expand All @@ -8616,15 +8605,6 @@ eslint-module-utils@^2.7.3, eslint-module-utils@^2.8.0:
dependencies:
debug "^3.2.7"

eslint-plugin-es-x@^7.5.0:
version "7.5.0"
resolved "https://registry.npmjs.org/eslint-plugin-es-x/-/eslint-plugin-es-x-7.5.0.tgz#d08d9cd155383e35156c48f736eb06561d07ba92"
integrity sha512-ODswlDSO0HJDzXU0XvgZ3lF3lS3XAZEossh15Q2UHjwrJggWeBoKqqEsLTZLXl+dh5eOAozG0zRcYtuE35oTuQ==
dependencies:
"@eslint-community/eslint-utils" "^4.1.2"
"@eslint-community/regexpp" "^4.6.0"
eslint-compat-utils "^0.1.2"

eslint-plugin-es@^3.0.0:
version "3.0.1"
resolved "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-3.0.1.tgz#75a7cdfdccddc0589934aeeb384175f221c57893"
Expand Down Expand Up @@ -8714,23 +8694,6 @@ [email protected]:
minimatch "^3.1.2"
semver "^6.3.0"

eslint-plugin-n@^16.6.1:
version "16.6.1"
resolved "https://registry.npmjs.org/eslint-plugin-n/-/eslint-plugin-n-16.6.1.tgz#b16e0033bc9ce592b1c3512cb1cee24f84ecb5ae"
integrity sha512-M1kE5bVQRLBMDYRZwDhWzlzbp370SRRRC1MHqq4I3L2Tatey+9/2csc5mwLDPlmhJaDvkojbrNUME5/llpRyDg==
dependencies:
"@eslint-community/eslint-utils" "^4.4.0"
builtins "^5.0.1"
eslint-plugin-es-x "^7.5.0"
get-tsconfig "^4.7.0"
globals "^13.24.0"
ignore "^5.2.4"
is-builtin-module "^3.2.1"
is-core-module "^2.12.1"
minimatch "^3.1.2"
resolve "^1.22.2"
semver "^7.5.3"

eslint-plugin-node@^11.1.0:
version "11.1.0"
resolved "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-11.1.0.tgz#c95544416ee4ada26740a30474eefc5402dc671d"
Expand All @@ -8750,11 +8713,6 @@ eslint-plugin-prettier@^4.2.1:
dependencies:
prettier-linter-helpers "^1.0.0"

eslint-plugin-promise@^6.1.1:
version "6.1.1"
resolved "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-6.1.1.tgz#269a3e2772f62875661220631bd4dafcb4083816"
integrity sha512-tjqWDwVZQo7UIPMeDReOpUgHCmCiH+ePnVT+5zVapL0uuHnegBUs2smM13CzOs2Xb5+MHMRFTs9v24yjba4Oig==

[email protected]:
version "4.6.0"
resolved "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.0.tgz#4c3e697ad95b77e93f8646aaa1630c1ba607edd3"
Expand Down Expand Up @@ -9668,13 +9626,6 @@ get-symbol-description@^1.0.0:
call-bind "^1.0.2"
get-intrinsic "^1.1.1"

get-tsconfig@^4.7.0:
version "4.7.2"
resolved "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.7.2.tgz#0dcd6fb330391d46332f4c6c1bf89a6514c2ddce"
integrity sha512-wuMsz4leaj5hbGgg4IvDU0bqJagpftG5l5cXIAvo8uZrqn0NJqwtfupTN00VnkQJPcIRrxYrm1Ue24btpCha2A==
dependencies:
resolve-pkg-maps "^1.0.0"

get-uri@^6.0.1:
version "6.0.2"
resolved "https://registry.npmjs.org/get-uri/-/get-uri-6.0.2.tgz#e019521646f4a8ff6d291fbaea2c46da204bb75b"
Expand Down Expand Up @@ -9785,13 +9736,6 @@ globals@^13.19.0:
dependencies:
type-fest "^0.20.2"

globals@^13.24.0:
version "13.24.0"
resolved "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz#8432a19d78ce0c1e833949c36adb345400bb1171"
integrity sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==
dependencies:
type-fest "^0.20.2"

globalthis@^1.0.1, globalthis@^1.0.3:
version "1.0.3"
resolved "https://registry.npmjs.org/globalthis/-/globalthis-1.0.3.tgz#5852882a52b80dc301b0660273e1ed082f0b6ccf"
Expand Down Expand Up @@ -10391,19 +10335,12 @@ is-buffer@^2.0.0:
resolved "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.5.tgz#ebc252e400d22ff8d77fa09888821a24a658c191"
integrity sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ==

is-builtin-module@^3.2.1:
version "3.2.1"
resolved "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.2.1.tgz#f03271717d8654cfcaf07ab0463faa3571581169"
integrity sha512-BSLE3HnV2syZ0FK0iMA/yUGplUeMmNz4AW5fnTunbCIqZi4vG3WjJT9FHMy5D69xmAYBHXQhJdALdpwVxV501A==
dependencies:
builtin-modules "^3.3.0"

is-callable@^1.1.3, is-callable@^1.1.4, is-callable@^1.2.7:
version "1.2.7"
resolved "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz#3bc2a85ea742d9e36205dcacdd72ca1fdc51b055"
integrity sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==

is-core-module@^2.12.1, is-core-module@^2.13.0, is-core-module@^2.13.1, is-core-module@^2.8.1:
is-core-module@^2.13.0, is-core-module@^2.13.1, is-core-module@^2.8.1:
version "2.13.1"
resolved "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.1.tgz#ad0d7532c6fea9da1ebdc82742d74525c6273384"
integrity sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==
Expand Down Expand Up @@ -13774,17 +13711,12 @@ resolve-from@^5.0.0:
resolved "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69"
integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==

resolve-pkg-maps@^1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz#616b3dc2c57056b5588c31cdf4b3d64db133720f"
integrity sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==

resolve.exports@^2.0.0:
version "2.0.2"
resolved "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.2.tgz#f8c934b8e6a13f539e38b7098e2e36134f01e800"
integrity sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg==

resolve@^1.1.4, resolve@^1.1.6, resolve@^1.10.0, resolve@^1.10.1, resolve@^1.14.2, resolve@^1.17.0, resolve@^1.19.0, resolve@^1.20.0, resolve@^1.22.0, resolve@^1.22.2, resolve@^1.22.3, resolve@^1.22.4, resolve@^1.4.0:
resolve@^1.1.4, resolve@^1.1.6, resolve@^1.10.0, resolve@^1.10.1, resolve@^1.14.2, resolve@^1.17.0, resolve@^1.19.0, resolve@^1.20.0, resolve@^1.22.0, resolve@^1.22.3, resolve@^1.22.4, resolve@^1.4.0:
version "1.22.8"
resolved "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz#b6c87a9f2aa06dfab52e3d70ac8cde321fa5a48d"
integrity sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==
Expand Down

0 comments on commit e3c476e

Please sign in to comment.