Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fastauth metamask #773

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/react/contexts/WalletSelectorContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import React, { useCallback, useContext, useEffect, useState } from "react";
import { distinctUntilChanged, map } from "rxjs";

import { setupNeth } from "@near-wallet-selector/neth";
import { setupFastAuthMetaMask } from "@near-wallet-selector/fastauth-metamask";
import { setupOptoWallet } from "@near-wallet-selector/opto-wallet";
import { setupFinerWallet } from "@near-wallet-selector/finer-wallet";
import { Loading } from "../components/Loading";
Expand Down Expand Up @@ -74,6 +75,7 @@ export const WalletSelectorContextProvider: React.FC<{
gas: "300000000000000",
bundle: false,
}),
setupFastAuthMetaMask(),
setupOptoWallet(),
setupFinerWallet(),
setupXDEFI(),
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"build:my-near-wallet": "nx run-many --target=build --projects=my-near-wallet --configuration=production",
"build:sender": "nx run-many --target=build --projects=sender --configuration=production",
"build:neth": "nx run-many --target=build --projects=neth --configuration=production",
"build:fastauth-metamask": "nx run-many --target=build --projects=fastauth-metamask --configuration=production",
"build:nearfi": "nx run-many --target=build --projects=nearfi --configuration=production",
"build:nightly": "nx run-many --target=build --projects=nightly --configuration=production",
"build:meteor-wallet": "nx run-many --target=build --projects=meteor-wallet --configuration=production",
Expand Down
18 changes: 18 additions & 0 deletions packages/fastauth-metamask/.eslintrc.json
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": {}
}
]
}
3 changes: 3 additions & 0 deletions packages/fastauth-metamask/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

kujtimprenkuSQA marked this conversation as resolved.
Show resolved Hide resolved
# dependencies
/node_modules
69 changes: 69 additions & 0 deletions packages/fastauth-metamask/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# @near-wallet-selector/fastauth-metamask

This is the [fastauth-metamask](https://fastauth-metamask.app) 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` v0.44.2 or above:
kujtimprenkuSQA marked this conversation as resolved.
Show resolved Hide resolved

```bash
# Using Yarn
yarn add near-api-js

# Using NPM.
npm install near-api-js
```
```bash
# Using Yarn
yarn add @near-wallet-selector/fastauth-metamask

# Using NPM.
npm install @near-wallet-selector/fastauth-metamask
```

Then use it in your dApp:

```ts
import { setupWalletSelector } from "@near-wallet-selector/core";
import { setupfastauth-metamask } from "@near-wallet-selector/fastauth-metamask";

// fastauth-metamask for Wallet Selector can be setup without any params or it can take one optional param.
const fastauth-metamask = setupfastauth-metamask({
// default fastauth-metamask icon included
iconUrl?: string;
// default 200 Tgas - for each fastauth-metamask transaction (bundling can include multiple "inner" transactions)
gas?: string;
// default false - cover screen with rgba(0, 0, 0, 0.5) mask while signing and awaiting transaction outcome
useModalCover?: boolean;
// default true - signAndSendTransactions will be bundled into 1 fastauth-metamask TX
bundle?: boolean,
// default false
deprecated?: boolean,
});

const selector = await setupWalletSelector({
network: "testnet",
modules: [fastauth-metamask],
});
```

## Options

Setup options are described in comments above

## Assets

Assets such as icons can be found in the `/assets` directory of the package. Below is an example using Webpack:

```ts
import { setupfastauth-metamask } from "@near-wallet-selector/fastauth-metamask";
import { nearWalletIcon } from "@near-wallet-selector/fastauth-metamask/assets/icons";

const fastauth-metamask = setupfastauth-metamask({
iconUrl: nearWalletIcon
});
```

## License

This repository is distributed under the terms of both the MIT license and the Apache License (Version 2.0).
14 changes: 14 additions & 0 deletions packages/fastauth-metamask/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
displayName: "fastauth-metamask",
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/fastauth-metamask",
};
15 changes: 15 additions & 0 deletions packages/fastauth-metamask/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* eslint-disable */
export default {
displayName: "fastauth-metamask",
preset: "../../jest.preset.js",
globals: {
"ts-jest": {
tsconfig: "<rootDir>/tsconfig.spec.json",
},
},
transform: {
"^.+\\.[tj]s$": "ts-jest",
},
moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
coverageDirectory: "../../coverage/packages/fastauth-metamask",
};
27 changes: 27 additions & 0 deletions packages/fastauth-metamask/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "@near-wallet-selector/fastauth-metamask",
"version": "7.9.2",
kujtimprenkuSQA marked this conversation as resolved.
Show resolved Hide resolved
"description": "Control NEAR accounts with ETH accounts",
"author": "mattlockyer",
"keywords": [
"near",
"blockchain",
"wallets",
"dapps",
"near-protocol",
"near-blockchain",
"wallet selector",
"fastauth-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/fastauth-metamask",
"peerDependencies": {
"near-api-js": "^0.44.2 || ^1.0.0"
}
kujtimprenkuSQA marked this conversation as resolved.
Show resolved Hide resolved
}
54 changes: 54 additions & 0 deletions packages/fastauth-metamask/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/fastauth-metamask/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nrwl/web:rollup",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/packages/fastauth-metamask",
"tsConfig": "packages/fastauth-metamask/tsconfig.lib.json",
"project": "packages/fastauth-metamask/package.json",
"entryFile": "packages/fastauth-metamask/src/index.ts",
"buildableProjectDepsInPackageJsonType": "dependencies",
"compiler": "babel",
"format": ["esm", "cjs"],
"assets": [
{
"glob": "packages/fastauth-metamask/README.md",
"input": ".",
"output": "."
},
{
"glob": "packages/fastauth-metamask/assets/*",
"input": ".",
"output": "assets"
}
]
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["packages/fastauth-metamask/**/*.ts"]
}
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": ["coverage/packages/fastauth-metamask"],
"options": {
"jestConfig": "packages/fastauth-metamask/jest.config.ts",
"passWithNoTests": true
}
},
"deploy": {
"executor": "ngx-deploy-npm:deploy",
"options": {
"access": "public"
}
}
},
"tags": ["injected-wallet"]
}
1 change: 1 addition & 0 deletions packages/fastauth-metamask/src/assets/icons.ts

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions packages/fastauth-metamask/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export type { FastAuthMetaMaskParams } from "./lib/fastauth-metamask";

export { setupFastAuthMetaMask } from "./lib/fastauth-metamask";
export {
getNear,
getConnection,
getEthereum,
handleCreate,
accountExists,
switchEthereum,
handleCheckAccount,
handleCancelFunding,
verifyOwner,
getNearMap,
handleDisconnect,
handleUpdateContract,
handleRefreshAppKey,
hasAppKey,
signIn,
signOut,
isSignedIn,
signAndSendTransactions,
initConnection,
MIN_NEW_ACCOUNT_ASK,
} from "./lib/neth-lib";
Loading