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

feat: Adding Meteor Wallet to the project #348

Merged
merged 8 commits into from
Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ NEAR Wallet Selector makes it easy for users to interact with your dApp by provi
- [Sender](https://www.npmjs.com/package/@near-wallet-selector/sender) - Injected wallet.
- [Math Wallet](https://www.npmjs.com/package/@near-wallet-selector/math-wallet) - Injected wallet.
- [Nightly](https://www.npmjs.com/package/@near-wallet-selector/nightly) - Injected wallet.
- [Meteor Wallet](https://www.npmjs.com/package/@near-wallet-selector/meteor-wallet) - Injected wallet.
- [Ledger](https://www.npmjs.com/package/@near-wallet-selector/ledger) - Hardware wallet.
- [WalletConnect](https://www.npmjs.com/package/@near-wallet-selector/wallet-connect) - Bridge wallet.
- [Nightly Connect](https://www.npmjs.com/package/@near-wallet-selector/nightly-connect) - Bridge wallet.
Expand Down Expand Up @@ -39,6 +40,7 @@ yarn add \
@near-wallet-selector/sender \
@near-wallet-selector/math-wallet \
@near-wallet-selector/nightly \
@near-wallet-selector/meteor-wallet \
@near-wallet-selector/ledger \
@near-wallet-selector/wallet-connect \
@near-wallet-selector/nightly-connect
Expand All @@ -50,6 +52,7 @@ npm install \
@near-wallet-selector/sender \
@near-wallet-selector/math-wallet \
@near-wallet-selector/nightly \
@near-wallet-selector/meteor-wallet \
@near-wallet-selector/ledger \
@near-wallet-selector/wallet-connect \
@near-wallet-selector/nightly-connect
Expand Down Expand Up @@ -78,6 +81,7 @@ import { setupNightly } from "@near-wallet-selector/nightly";
import { setupLedger } from "@near-wallet-selector/ledger";
import { setupWalletConnect } from "@near-wallet-selector/wallet-connect";
import { setupNightlyConnect } from "@near-wallet-selector/nightly-connect";
import { setupMeteorWallet } from "@near-wallet-selector/meteor-wallet";

const selector = await setupWalletSelector({
network: "testnet",
Expand All @@ -87,6 +91,7 @@ const selector = await setupWalletSelector({
setupSender(),
setupMathWallet(),
setupNightly(),
setupMeteorWallet(),
setupLedger(),
setupWalletConnect({
projectId: "c4f79cc...",
Expand Down
5 changes: 5 additions & 0 deletions examples/angular/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
"glob": "**/*",
"input": "packages/nightly-connect/assets/",
"output": "assets/"
},
{
"glob": "**/*",
"input": "packages/meteor-wallet/assets/",
"output": "assets/"
}
],
"styles": ["examples/angular/src/styles.scss"],
Expand Down
2 changes: 2 additions & 0 deletions examples/react/contexts/WalletSelectorContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { setupNightly } from "@near-wallet-selector/nightly";
import { setupLedger } from "@near-wallet-selector/ledger";
import { setupWalletConnect } from "@near-wallet-selector/wallet-connect";
import { setupNightlyConnect } from "@near-wallet-selector/nightly-connect";
import { setupMeteorWallet } from "@near-wallet-selector/meteor-wallet";
import { CONTRACT_ID } from "../constants";

declare global {
Expand Down Expand Up @@ -47,6 +48,7 @@ export const WalletSelectorContextProvider: React.FC = ({ children }) => {
setupMathWallet(),
setupNightly(),
setupLedger(),
setupMeteorWallet(),
setupWalletConnect({
projectId: "c4f79cc...",
metadata: {
Expand Down
5 changes: 5 additions & 0 deletions examples/react/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
"glob": "**/*",
"input": "packages/nightly-connect/assets/",
"output": "assets/"
},
{
"glob": "**/*",
"input": "packages/meteor-wallet/assets/",
"output": "assets/"
}
]
},
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"nightly",
"ledger",
"wallet-connect",
"nightly-connect"
"nightly-connect",
"meteor-wallet"
],
"homepage": "https://github.com/near/wallet-selector#README",
"bugs": {
Expand All @@ -42,6 +43,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:nightly": "nx run-many --target=build --projects=nightly --configuration=production",
"build:meteor-wallet": "nx run-many --target=build --projects=meteor-wallet --configuration=production",
"build:wallet-connect": "nx run-many --target=build --projects=wallet-connect --configuration=production",
"build:nightly-connect": "nx run-many --target=build --projects=nightly-connect --configuration=production",
"build:wallet-utils": "nx run-many --target=build --projects=wallet-utils --configuration=production",
Expand All @@ -67,6 +69,7 @@
"@ledgerhq/hw-transport": "^6.20.0",
"@ledgerhq/hw-transport-webhid": "^6.20.0",
"@ledgerhq/logs": "^6.10.0",
"@meteorwallet/sdk": "^0.0.9",
"@nightlylabs/connect": "0.0.23",
"@nrwl/next": "13.8.5",
"@walletconnect/qrcode-modal": "2.0.0-alpha.20",
Expand Down
3 changes: 3 additions & 0 deletions packages/meteor-wallet/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": [["@nrwl/web/babel", { "useBuiltIns": "usage" }]]
}
18 changes: 18 additions & 0 deletions packages/meteor-wallet/.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": {}
}
]
}
53 changes: 53 additions & 0 deletions packages/meteor-wallet/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# @near-wallet-selector/meteor-wallet

This is the [Meteor Wallet](https://meteorwallet.app) package for NEAR Wallet Selector.

## Installation and Usage

The easiest way to use this package is to install it from the NPM registry:

```bash
# Using Yarn
yarn add @near-wallet-selector/meteor-wallet

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

Then use it in your dApp:

```ts
import { setupWalletSelector } from "@near-wallet-selector/core";
import { setupMeteorWallet } from "@near-wallet-selector/meteor-wallet";

// Meteor for Wallet Selector can be setup without any params or it can take one optional param.
const meteorWallet = setupMeteorWallet({
iconUrl: "https://yourdomain.com/yourwallet-icon.png" //optional
});

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

## Options

- `iconUrl`: (`string?`): Image URL for the icon shown in the modal. This can also be a relative path or base64 encoded image. Defaults to `./assets/meteor-icon.png`.

## Assets

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

```ts
import { setupMeteorWallet } from "@near-wallet-selector/meteor-wallet";
import meteorIconUrl from "@near-wallet-selector/meteor-wallet/assets/meteor-icon.png";

const meteorWallet = setupMeteorWallet({
iconUrl: meteorIconUrl
});
```

## License

This repository is distributed under the terms of both the MIT license and the Apache License (Version 2.0).
Binary file added packages/meteor-wallet/assets/meteor-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions packages/meteor-wallet/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
displayName: "meteor-wallet",
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/meteor-wallet",
};
4 changes: 4 additions & 0 deletions packages/meteor-wallet/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "@near-wallet-selector/meteor-wallet",
"version": "5.0.0"
}
54 changes: 54 additions & 0 deletions packages/meteor-wallet/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"root": "packages/meteor-wallet",
"sourceRoot": "packages/meteor-wallet/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nrwl/web:rollup",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/packages/meteor-wallet",
"tsConfig": "packages/meteor-wallet/tsconfig.lib.json",
"project": "packages/meteor-wallet/package.json",
"entryFile": "packages/meteor-wallet/src/index.ts",
"buildableProjectDepsInPackageJsonType": "dependencies",
"compiler": "babel",
"format": ["esm", "umd", "cjs"],
"assets": [
{
"glob": "packages/meteor-wallet/README.md",
"input": ".",
"output": "."
},
{
"glob": "packages/meteor-wallet/assets/*",
"input": ".",
"output": "assets"
}
]
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["packages/meteor-wallet/**/*.ts"]
}
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": ["coverage/packages/meteor-wallet"],
"options": {
"jestConfig": "packages/meteor-wallet/jest.config.js",
"passWithNoTests": true
}
},
"deploy": {
"executor": "ngx-deploy-npm:deploy",
"options": {
"access": "public"
}
}
},
"tags": ["injected-wallet"]
}
1 change: 1 addition & 0 deletions packages/meteor-wallet/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { setupMeteorWallet } from "./lib/meteor-wallet";
11 changes: 11 additions & 0 deletions packages/meteor-wallet/src/lib/meteor-wallet-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { MeteorWallet as MeteorWalletSdk } from "@meteorwallet/sdk";
import { keyStores } from "near-api-js";

export interface MeteorWalletParams_Injected {
iconUrl?: string;
}

export interface MeteorWalletState {
wallet: MeteorWalletSdk;
keyStore: keyStores.BrowserLocalStorageKeyStore;
}
Loading