-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
246e235
commit 4889aa8
Showing
12 changed files
with
11,091 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module.exports = { | ||
extends: ['../../.eslintrc.js'], | ||
|
||
parserOptions: { | ||
tsconfigRootDir: __dirname, | ||
}, | ||
|
||
overrides: [ | ||
{ | ||
files: ['snap.config.ts'], | ||
extends: ['@metamask/eslint-config-nodejs'], | ||
}, | ||
|
||
{ | ||
files: ['**/*.ts', '**/*.tsx'], | ||
extends: ['@metamask/eslint-config-typescript'], | ||
rules: { | ||
// This allows importing the `Text` JSX component. | ||
'@typescript-eslint/no-shadow': [ | ||
'error', | ||
{ | ||
allow: ['Text'], | ||
}, | ||
], | ||
}, | ||
}, | ||
|
||
{ | ||
files: ['*.test.ts', '*.test.tsx'], | ||
rules: { | ||
'@typescript-eslint/unbound-method': 'off', | ||
}, | ||
}, | ||
], | ||
|
||
ignorePatterns: ['!.eslintrc.js', 'dist/'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
.DS_Store | ||
dist/ | ||
build/ | ||
coverage/ | ||
.cache/ | ||
public/ | ||
|
||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
.env.test | ||
|
||
# Stores VSCode versions used for testing VSCode extensions | ||
.vscode-test | ||
|
||
# yarn v2 | ||
.yarn/cache | ||
.yarn/unplugged | ||
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
preset: '@metamask/snaps-jest', | ||
transform: { | ||
'^.+\\.(t|j)sx?$': 'ts-jest', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
{ | ||
"name": "unstoppable-snap", | ||
"version": "0.0.1", | ||
"description": "The Official Unstoppable Domains Resolution Snap.", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/unstoppabledomains/unstoppable-resolution-snap" | ||
}, | ||
"license": "(MIT-0 OR Apache-2.0)", | ||
"main": "./dist/bundle.js", | ||
"files": [ | ||
"dist/", | ||
"images/icon.svg", | ||
"snap.manifest.json" | ||
], | ||
"scripts": { | ||
"allow-scripts": "yarn workspace root allow-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", | ||
"prepublishOnly": "mm-snap manifest", | ||
"serve": "mm-snap serve", | ||
"start": "mm-snap watch", | ||
"test": "jest" | ||
}, | ||
"dependencies": { | ||
"@metamask/snaps-sdk": "^6.1.1", | ||
"buffer": "^6.0.3", | ||
"dotenv": "^16.4.5" | ||
}, | ||
"devDependencies": { | ||
"@jest/globals": "^29.5.0", | ||
"@metamask/auto-changelog": "^3.4.4", | ||
"@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/snaps-cli": "^6.2.1", | ||
"@metamask/snaps-jest": "^8.2.0", | ||
"@typescript-eslint/eslint-plugin": "^5.42.1", | ||
"@typescript-eslint/parser": "^5.42.1", | ||
"eslint": "^8.45.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-import": "~2.26.0", | ||
"eslint-plugin-jest": "^27.1.5", | ||
"eslint-plugin-jsdoc": "^41.1.2", | ||
"eslint-plugin-n": "^15.7.0", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"eslint-plugin-promise": "^6.1.1", | ||
"jest": "^29.5.0", | ||
"prettier": "^2.7.1", | ||
"prettier-plugin-packagejson": "^2.2.11", | ||
"rimraf": "^3.0.2", | ||
"ts-jest": "^29.1.0", | ||
"typescript": "^4.7.4" | ||
}, | ||
"packageManager": "yarn@3.2.1", | ||
"engines": { | ||
"node": ">=18.6.0" | ||
}, | ||
"publishConfig": { | ||
"access": "public", | ||
"registry": "https://registry.npmjs.org/" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import type { SnapConfig } from '@metamask/snaps-cli'; | ||
import { resolve } from 'path'; | ||
import * as dotenv from "dotenv" | ||
dotenv.config({}); | ||
|
||
const config: SnapConfig = { | ||
bundler: 'webpack', | ||
input: resolve(__dirname, 'src/index.tsx'), | ||
server: { | ||
port: 8080, | ||
}, | ||
polyfills: { | ||
buffer: true, | ||
}, | ||
environment: { | ||
UNSTOPPABLE_API_KEY: process.env.UNSTOPPABLE_API_KEY, | ||
} | ||
}; | ||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
{ | ||
"version": "0.0.1", | ||
"description": "The Official Unstoppable Domains Resolution Snap", | ||
"proposedName": "Unstoppable", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/unstoppabledomains/unstoppable-resolution-snap" | ||
}, | ||
"source": { | ||
"shasum": "p14Kc1ZsWOplXdWhMuT6W+m+yo74C0P4Fm19DIWy75U=", | ||
"location": { | ||
"npm": { | ||
"filePath": "dist/bundle.js", | ||
"iconPath": "images/icon.svg", | ||
"packageName": "unstoppable-snap", | ||
"registry": "https://registry.npmjs.org/" | ||
} | ||
} | ||
}, | ||
"initialPermissions": { | ||
"snap_notify": {}, | ||
"endowment:name-lookup": { | ||
"chains": [ | ||
"eip155:1", | ||
"eip155:137", | ||
"eip155:43114", | ||
"eip155:56", | ||
"eip155:250" | ||
], | ||
"matchers": { | ||
"tlds": [ | ||
"crypto", | ||
"nft", | ||
"bitcoin", | ||
"blockchain", | ||
"unstoppable", | ||
"dao", | ||
"888", | ||
"wallet", | ||
"x", | ||
"klever", | ||
"hi", | ||
"kresus", | ||
"polygon", | ||
"anime", | ||
"manga", | ||
"binanceus", | ||
"go", | ||
"altimist", | ||
"pudgy", | ||
"austin", | ||
"bitget", | ||
"pog", | ||
"clay", | ||
"witg", | ||
"metropolis", | ||
"wrkx", | ||
"secret", | ||
"raiin", | ||
"stepn", | ||
"kryptic", | ||
"ubu", | ||
"tball", | ||
"farms", | ||
"dfz", | ||
"zil", | ||
"com", | ||
"ca", | ||
"eth" | ||
] | ||
} | ||
}, | ||
"endowment:rpc": { | ||
"dapps": true, | ||
"snaps": true | ||
}, | ||
"endowment:network-access": {}, | ||
"endowment:cronjob": { | ||
"jobs": [ | ||
{ | ||
"expression": "0 0 * * 0", | ||
"request": { | ||
"method": "execute" | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
"manifestVersion": "0.1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { expect } from '@jest/globals'; | ||
import { installSnap } from '@metamask/snaps-jest'; | ||
import { Box, Text, Bold } from '@metamask/snaps-sdk/jsx'; | ||
|
||
describe('onRpcRequest', () => { | ||
describe('hello', () => { | ||
it('shows a confirmation dialog', async () => { | ||
const { request } = await installSnap(); | ||
|
||
const origin = 'Jest'; | ||
const response = request({ | ||
method: 'hello', | ||
origin, | ||
}); | ||
|
||
const ui = await response.getInterface(); | ||
expect(ui.type).toBe('confirmation'); | ||
expect(ui).toRender( | ||
<Box> | ||
<Text> | ||
Hello, <Bold>{origin}</Bold>! | ||
</Text> | ||
<Text>This custom confirmation is just for display purposes.</Text> | ||
<Text> | ||
But you can edit the snap source code to make it do something, if | ||
you want to! | ||
</Text> | ||
</Box>, | ||
); | ||
|
||
await ui.ok(); | ||
|
||
expect(await response).toRespondWith(true); | ||
}); | ||
}); | ||
|
||
it('throws an error if the requested method does not exist', async () => { | ||
const { request } = await installSnap(); | ||
|
||
const response = await request({ | ||
method: 'foo', | ||
}); | ||
|
||
expect(response).toRespondWithError({ | ||
code: -32603, | ||
message: 'Method not found.', | ||
stack: expect.any(String), | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.