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

Add support for NearMobileWallet #931

Merged
merged 13 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from 9 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
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ NEAR Wallet Selector makes it easy for users to interact with your dApp by provi
- [NearFi Wallet](https://www.npmjs.com/package/@near-wallet-selector/nearfi) - Mobile wallet.
- [Opto Wallet](https://www.npmjs.com/package/@near-wallet-selector/opto-wallet) - Mobile wallet & Browser wallet.
- [Ramper Wallet](https://www.npmjs.com/package/@near-wallet-selector/ramper-wallet) - Browser wallet.
- [Near Mobile Wallet](https://nearmobile.app/) - Mobile Wallet.

## Preview

Expand Down Expand Up @@ -72,7 +73,8 @@ yarn add \
@near-wallet-selector/opto-wallet \
@near-wallet-selector/neth \
@near-wallet-selector/xdefi \
@near-wallet-selector/ramper-wallet
@near-wallet-selector/ramper-wallet \
@near-wallet-selector/near-mobile-wallet

# Using NPM.
npm install \
Expand All @@ -95,7 +97,8 @@ npm install \
@near-wallet-selector/opto-wallet \
@near-wallet-selector/neth \
@near-wallet-selector/xdefi \
@near-wallet-selector/ramper-wallet
@near-wallet-selector/ramper-wallet \
@near-wallet-selector/near-mobile-wallet
```

Optionally, you can install our [`modal-ui`](https://www.npmjs.com/package/@near-wallet-selector/modal-ui) or [`modal-ui-js`](https://www.npmjs.com/package/@near-wallet-selector/modal-ui-js) package for a pre-built interface that wraps the `core` API and presents the supported wallets:
Expand Down Expand Up @@ -133,6 +136,7 @@ import { setupOptoWallet } from "@near-wallet-selector/opto-wallet";
import { setupNeth } from "@near-wallet-selector/neth";
import { setupXDEFI } from "@near-wallet-selector/xdefi";
import { setupRamperWallet } from "@near-wallet-selector/ramper-wallet";
import { setupNearMobileWallet } from "@near-wallet-selector/near-mobile-wallet";

const selector = await setupWalletSelector({
network: "testnet",
Expand Down Expand Up @@ -171,6 +175,7 @@ const selector = await setupWalletSelector({
icon: "https://near.org/wp-content/uploads/2020/09/cropped-favicon-192x192.png",
},
}),
setupNearMobileWallet(),
],
});

Expand Down
5 changes: 5 additions & 0 deletions examples/angular/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@
"glob": "**/*",
"input": "packages/ramper-wallet/assets/",
"output": "assets/"
},
{
"glob": "**/*",
"input": "packages/near-mobile-wallet/assets/",
"output": "assets/"
}
],
"styles": ["examples/angular/src/styles.scss"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { Component } from "@angular/core";
import { setupExportSelectorModal } from "@near-wallet-selector/account-export";
import { setupMyNearWallet } from "@near-wallet-selector/my-near-wallet";
import { setupRamperWallet } from "@near-wallet-selector/ramper-wallet";
import { setupNearMobileWallet } from "@near-wallet-selector/near-mobile-wallet";
import { setupLedger } from "@near-wallet-selector/ledger";

declare global {
Expand Down Expand Up @@ -91,6 +92,7 @@ export class WalletSelectorExportComponent implements OnInit {
},
}),
setupRamperWallet(),
setupNearMobileWallet(),
],
});
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { Component } from "@angular/core";
import { setupMyNearWallet } from "@near-wallet-selector/my-near-wallet";
import { setupRamperWallet } from "@near-wallet-selector/ramper-wallet";
import { setupLedger } from "@near-wallet-selector/ledger";
import { setupNearMobileWallet } from "@near-wallet-selector/near-mobile-wallet";
import { CONTRACT_ID } from "../../../constants";

declare global {
Expand Down Expand Up @@ -94,6 +95,7 @@ export class WalletSelectorComponent implements OnInit {
},
}),
setupRamperWallet(),
setupNearMobileWallet(),
],
});

Expand Down
3 changes: 3 additions & 0 deletions examples/react/contexts/WalletSelectorContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import { setupMyNearWallet } from "@near-wallet-selector/my-near-wallet";
import { setupLedger } from "@near-wallet-selector/ledger";
import { setupXDEFI } from "@near-wallet-selector/xdefi";
import { setupRamperWallet } from "@near-wallet-selector/ramper-wallet";
import { setupNearMobileWallet } from "@near-wallet-selector/near-mobile-wallet";

import type { ReactNode } from "react";
import React, {
useCallback,
Expand Down Expand Up @@ -104,6 +106,7 @@ export const WalletSelectorContextProvider: React.FC<{
icon: "https://near.org/wp-content/uploads/2020/09/cropped-favicon-192x192.png",
},
}),
setupNearMobileWallet(),
],
});
const _modal = setupModal(_selector, {
Expand Down
2 changes: 2 additions & 0 deletions examples/react/contexts/WalletSelectorExportContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { Loading } from "../components/Loading";
import { setupMyNearWallet } from "@near-wallet-selector/my-near-wallet";
import { setupLedger } from "@near-wallet-selector/ledger";
import { setupRamperWallet } from "@near-wallet-selector/ramper-wallet";
import { setupNearMobileWallet } from "@near-wallet-selector/near-mobile-wallet";

declare global {
interface Window {
Expand Down Expand Up @@ -89,6 +90,7 @@ export const ExportAccountSelectorContextProvider: React.FC<{
icon: "https://near.org/wp-content/uploads/2020/09/cropped-favicon-192x192.png",
},
}),
setupNearMobileWallet(),
],
});
/**
Expand Down
5 changes: 5 additions & 0 deletions examples/react/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@
"glob": "**/*",
"input": "packages/ramper-wallet/assets/",
"output": "assets/"
},
{
"glob": "**/*",
"input": "packages/near-mobile-wallet/assets/",
"output": "assets/"
}
]
},
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "near-wallet-selector",
"version": "8.5.2",
"version": "8.5.3",
"description": "NEAR Wallet Selector makes it easy for users to interact with your dApp by providing an abstraction over various wallets within the NEAR ecosystem",
"keywords": [
"near",
Expand All @@ -24,7 +24,8 @@
"welldone-wallet",
"opto-wallet",
"finer-wallet",
"ramper-wallet"
"ramper-wallet",
"near-mobile-wallet"
],
"homepage": "https://github.com/near/wallet-selector#README",
"bugs": {
Expand Down Expand Up @@ -67,6 +68,7 @@
"build:near-snap": "nx run-many --target=build --projects=near-snap --configuration=production",
"build:account-export": "nx run-many --target=build --projects=account-export --configuration=production",
"build:ramper-wallet": "nx run-many --target=build --projects=ramper-wallet --configuration=production",
"build:near-mobile-wallet": "nx run-many --target=build --projects=near-mobile-wallet --configuration=production",
"lint": "nx workspace-lint && nx run-many --target=lint --all --parallel",
"lint:fix": "nx run-many --target=lint --all --fix",
"serve:react": "nx serve react --host=0.0.0.0",
Expand All @@ -93,6 +95,7 @@
"@meteorwallet/sdk": "^0.8.0",
"@near-snap/sdk": "^0.5.0",
"@nightlylabs/connect-near": "0.0.15",
"@peersyst/near-mobile-signer": "1.0.2",
"@ramper/near": "^0.0.30",
"@walletconnect/modal": "^2.6.0",
"@walletconnect/sign-client": "2.9.1",
Expand Down
10 changes: 10 additions & 0 deletions packages/near-mobile-wallet/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"presets": [
[
"@nrwl/js/babel",
{
"useBuiltIns": "usage"
}
]
]
}
18 changes: 18 additions & 0 deletions packages/near-mobile-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": {}
}
]
}
50 changes: 50 additions & 0 deletions packages/near-mobile-wallet/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# @near-wallet-selector/near-mobile-wallet

This is the [Near Mobile Wallet](https://nearmobile.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` 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/near-mobile-wallet

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

Then use it in your dApp:

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

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

## Options

- `dAppMetadata: DAppMetadata` (optional): An object to provide data from your dApp to be displayed on Near Mobile Wallet when signing requests.
```ts
export interface DAppMetadata {
name: string;
logoUrl: string;
url?: string;
}
```

## License

This repository is distributed under the terms of both the MIT license and the Apache License (Version 2.0).
Binary file added packages/near-mobile-wallet/assets/icon.png
erditkurteshiSQA marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions packages/near-mobile-wallet/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* eslint-disable */
export default {
displayName: "near-mobile-wallet",
preset: "../../jest.preset.js",
globals: {},
transform: {
"^.+\\.[tj]s$": [
"ts-jest",
{
tsconfig: "<rootDir>/tsconfig.spec.json",
},
],
},
moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
coverageDirectory: "../../coverage/packages/ramper-wallet",
Copy link
Contributor

@erditkurteshiSQA erditkurteshiSQA Oct 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please update the coverageDirectory to the near-mobile-wallet?

};
27 changes: 27 additions & 0 deletions packages/near-mobile-wallet/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "@near-wallet-selector/near-mobile-wallet",
"version": "8.5.3",
"description": "NEAR Mobile wallet package for NEAR Wallet Selector.",
"keywords": [
"near",
"blockchain",
"wallets",
"dapps",
"near-protocol",
"near-blockchain",
"wallet selector",
"injected wallet",
"near-mobile-wallet"
],
"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/near-mobile-wallet",
"peerDependencies": {
"near-api-js": "^1.0.0 || ^2.0.0"
}
}
56 changes: 56 additions & 0 deletions packages/near-mobile-wallet/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "near-mobile-wallet",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/near-mobile-wallet/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nrwl/rollup:rollup",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/packages/near-mobile-wallet",
"tsConfig": "packages/near-mobile-wallet/tsconfig.lib.json",
"project": "packages/near-mobile-wallet/package.json",
"entryFile": "packages/near-mobile-wallet/src/index.ts",
"buildableProjectDepsInPackageJsonType": "dependencies",
"compiler": "babel",
"format": ["esm", "cjs"],
"assets": [
{
"glob": "packages/near-mobile-wallet/README.md",
"input": ".",
"output": "."
},
{
"glob": "packages/near-mobile-wallet/assets/*",
"input": ".",
"output": "assets"
}
]
}
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["packages/near-mobile-wallet/**/*.ts"]
}
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/packages/near-mobile-wallet"],
"options": {
"jestConfig": "packages/near-mobile-wallet/jest.config.ts",
"passWithNoTests": true
}
},
"deploy": {
"executor": "ngx-deploy-npm:deploy",
"options": {
"access": "public"
},
"dependsOn": ["^deploy"]
}
},
"tags": ["injected-wallet"]
}
1 change: 1 addition & 0 deletions packages/near-mobile-wallet/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { setupNearMobileWallet } from "./lib/near-mobile-wallet";
1 change: 1 addition & 0 deletions packages/near-mobile-wallet/src/lib/icon.ts

Large diffs are not rendered by default.

Loading
Loading