-
Notifications
You must be signed in to change notification settings - Fork 150
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
Showing
21 changed files
with
766 additions
and
29 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
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
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
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,10 @@ | ||
{ | ||
"presets": [ | ||
[ | ||
"@nrwl/js/babel", | ||
{ | ||
"useBuiltIns": "usage" | ||
} | ||
] | ||
] | ||
} |
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,18 @@ | ||
{ | ||
"extends": ["../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"rules": {} | ||
} | ||
] | ||
} |
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,65 @@ | ||
# @near-wallet-selector/metamask-snap | ||
|
||
This is the NEAR Metamask Snap package for NEAR Wallet Selector. | ||
|
||
## Installation and Usage | ||
|
||
The easiest way to use this package is to install it from the NPM registry, this package requires `near-api-js` v1.0.0 or above: | ||
|
||
```bash | ||
# Using Yarn | ||
yarn add near-api-js | ||
|
||
# Using NPM. | ||
npm install near-api-js | ||
``` | ||
|
||
```bash | ||
# Using Yarn | ||
yarn add @near-wallet-selector/metamask-snap | ||
|
||
# Using NPM. | ||
npm install @near-wallet-selector/metamask-snap | ||
``` | ||
|
||
Then use it in your dApp: | ||
|
||
```ts | ||
import { setupWalletSelector } from "@near-wallet-selector/core"; | ||
import { setupMetamaskSnap } from "@near-wallet-selector/metamask-snap"; | ||
|
||
const selector = await setupWalletSelector({ | ||
network: "testnet", | ||
modules: [setupMetamaskSnap()], | ||
}); | ||
``` | ||
|
||
|
||
## Here Wallet JS SDK | ||
|
||
The library uses @near-snap/sdk, you can read more about the functionality here: | ||
https://github.com/here-wallet/near-snap | ||
|
||
|
||
## Options | ||
|
||
- `iconUrl`: (`string?`): Icon is optional. Default image point to Here Wallet Logo in base64 format. | ||
- `deprecated`: (`boolean?`): Deprecated is optional. Default is `false`. | ||
|
||
## Assets | ||
|
||
Assets such as icons can be found in the `/assets` directory of the package. Below is an example using Webpack: | ||
|
||
```ts | ||
import { setupMetamaskSnap } from "@near-wallet-selector/metamask-snap"; | ||
import SnapIconUrl from "@near-wallet-selector/metamask-snap/assets/snap-icon.png"; | ||
|
||
const snapWallet = setupMetamaskSnap({ | ||
iconUrl: SnapIconUrl | ||
}); | ||
|
||
``` | ||
|
||
## License | ||
|
||
This repository is distributed under the terms of both the MIT license and the Apache License (Version 2.0). |
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,14 @@ | ||
module.exports = { | ||
displayName: "metamask-snap", | ||
preset: "../../jest.preset.js", | ||
globals: { | ||
"ts-jest": { | ||
tsconfig: "<rootDir>/tsconfig.spec.json", | ||
}, | ||
}, | ||
transform: { | ||
"^.+\\.[tj]sx?$": "ts-jest", | ||
}, | ||
moduleFileExtensions: ["ts", "tsx", "js", "jsx"], | ||
coverageDirectory: "../../coverage/packages/metamask-snap", | ||
}; |
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,16 @@ | ||
/* eslint-disable */ | ||
export default { | ||
displayName: "metamask-snap", | ||
preset: "../../jest.preset.js", | ||
globals: {}, | ||
transform: { | ||
"^.+\\.[tj]s$": [ | ||
"ts-jest", | ||
{ | ||
tsconfig: "<rootDir>/tsconfig.spec.json", | ||
}, | ||
], | ||
}, | ||
moduleFileExtensions: ["ts", "tsx", "js", "jsx"], | ||
coverageDirectory: "../../coverage/packages/metamask-snap", | ||
}; |
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,30 @@ | ||
{ | ||
"name": "@near-wallet-selector/metamask-snap", | ||
"version": "8.2.0", | ||
"description": "Metamask Near Snap package for NEAR Wallet Selector.", | ||
"keywords": [ | ||
"near", | ||
"blockchain", | ||
"wallets", | ||
"dapps", | ||
"near-protocol", | ||
"near-blockchain", | ||
"wallet selector", | ||
"injected wallet", | ||
"metamask" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/near/wallet-selector.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/near/wallet-selector/issues" | ||
}, | ||
"homepage": "https://github.com/near/wallet-selector/tree/main/packages/metamask-snap", | ||
"peerDependencies": { | ||
"near-api-js": "^1.0.0 || ^2.0.0" | ||
}, | ||
"dependencies": { | ||
"@near-snap/sdk": "^0.2.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,55 @@ | ||
{ | ||
"name": "metamask-snap", | ||
"$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "packages/metamask-snap/src", | ||
"projectType": "library", | ||
"targets": { | ||
"build": { | ||
"executor": "@nrwl/rollup:rollup", | ||
"outputs": ["{options.outputPath}"], | ||
"options": { | ||
"outputPath": "dist/packages/metamask-snap", | ||
"tsConfig": "packages/metamask-snap/tsconfig.lib.json", | ||
"project": "packages/metamask-snap/package.json", | ||
"entryFile": "packages/metamask-snap/src/index.ts", | ||
"buildableProjectDepsInPackageJsonType": "dependencies", | ||
"compiler": "babel", | ||
"format": ["esm", "cjs"], | ||
"assets": [ | ||
{ | ||
"glob": "packages/metamask-snap/README.md", | ||
"input": ".", | ||
"output": "." | ||
}, | ||
{ | ||
"glob": "packages/metamask-snap/assets/*", | ||
"input": ".", | ||
"output": "assets" | ||
} | ||
] | ||
} | ||
}, | ||
"lint": { | ||
"executor": "@nx/linter:eslint", | ||
"outputs": ["{options.outputFile}"], | ||
"options": { | ||
"lintFilePatterns": ["packages/metamask-snap/**/*.ts"] | ||
} | ||
}, | ||
"test": { | ||
"executor": "@nx/jest:jest", | ||
"outputs": ["{workspaceRoot}/coverage/packages/metamask-snap"], | ||
"options": { | ||
"jestConfig": "packages/metamask-snap/jest.config.ts", | ||
"passWithNoTests": true | ||
} | ||
}, | ||
"deploy": { | ||
"executor": "ngx-deploy-npm:deploy", | ||
"options": { | ||
"access": "public" | ||
} | ||
} | ||
}, | ||
"tags": ["browser-wallet"] | ||
} |
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 @@ | ||
export { setupMetamaskSnap } from "./lib"; |
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 @@ | ||
export default "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGcgY2xpcC1wYXRoPSJ1cmwoI2NsaXAwXzFfNCkiPgo8cGF0aCBkPSJNMTcuMDM3IDBINi45NzQ5OUMyLjYwNTA0IDAgLTkuNTM2NzNlLTA3IDIuNjE1NjkgLTkuNTM2NzNlLTA3IDYuOTgzNTFWMTcuMDI4NUMtOS41MzY3M2UtMDcgMjEuMzk2MyAyLjYwNTA0IDI0IDYuOTc0OTkgMjRIMTcuMDI1QzIxLjM5NDkgMjQgMjQgMjEuMzk2MyAyNCAxNy4wMjc1VjYuOTg0NTFDMjQuMDEyIDIuNjE1NjkgMjEuNDA2OSAwIDE3LjAzNyAwWiIgZmlsbD0iIzI0MjcyQSIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTcuMDc1NzcgNi4wMTg0M0M2Ljc2MjgxIDYuMDYwNTkgNi40NzY5MyA2LjIyMDE2IDYuMjY5NzQgNi40NjgzNUM2LjExMjg1IDYuNjU2MjkgNi4wMTExMyA2Ljg5NDEzIDUuOTgwOTUgNy4xNDM1NEM1Ljk3NjggNy4xNzc5MSA1Ljk3NDgzIDguNzU1MzMgNS45NzQ5MiAxMi4wMDlDNS45NzUwMSAxNi4xMTggNS45NzYyNyAxNi44MzI5IDUuOTgzNDkgMTYuODg2N0M2LjA2MTUxIDE3LjQ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yNCIgaGVpZ2h0PSIyNCIgZmlsbD0id2hpdGUiLz4KPC9jbGlwUGF0aD4KPC9kZWZzPgo8L3N2Zz4K"; |
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,26 @@ | ||
import type { WalletModuleFactory } from "@near-wallet-selector/core"; | ||
import { initMetamaskSnap } from "./selector"; | ||
import icon from "./icon"; | ||
|
||
export { icon }; | ||
|
||
export function setupMetamaskSnap({ | ||
deprecated = false, | ||
iconUrl = icon, | ||
}): WalletModuleFactory { | ||
return async () => { | ||
return { | ||
id: "metamask-snap", | ||
type: "injected", | ||
init: initMetamaskSnap, | ||
metadata: { | ||
name: "Metamask Snap", | ||
description: "Metamask plugin for NEAR Protocol", | ||
downloadUrl: "https://near-snap.surge.sh", | ||
iconUrl, | ||
deprecated, | ||
available: true, | ||
}, | ||
}; | ||
}; | ||
} |
Oops, something went wrong.