Skip to content

Commit

Permalink
Merge branch 'dev' into SQC-540/add-signin-multi
Browse files Browse the repository at this point in the history
  • Loading branch information
kujtimprenkuSQA committed Sep 18, 2023
2 parents 9c487aa + 730c89b commit 8433139
Show file tree
Hide file tree
Showing 102 changed files with 2,064 additions and 672 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/change_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Change request
about: Template for change requests
title: ''
labels: task
labels: change-request
assignees: ''

---
Expand Down
26 changes: 26 additions & 0 deletions .github/ISSUE_TEMPLATE/epic-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: Epic Template
about: Epics are milestones or groups of alike issues
title: "[Epic] "
labels: Emerging Tech, Epic, Near BOS
assignees: ''

---

### Description

(Overview of milestone or function governed by this epic)

### Resources

(Relevant documentation, Figma links, and other reference material)

Item 1

Item 2

Item 3

```[tasklist]
### Related Issues
```
16 changes: 16 additions & 0 deletions .github/ISSUE_TEMPLATE/issue-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: Issue Template
about: Issues are general tasks to be compeleted
title: ''
labels: Emerging Tech, Near BOS
assignees: ''

---

### Description

(Summary of task, purpose, impact)

### Optional: User Story

(As a [user], I need [function, outcome, enhancement] that [provides value].)
17 changes: 15 additions & 2 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ on:
- main
workflow_dispatch:

permissions:
actions: write
issues: write
pull-requests: write

jobs:
release:
env:
Expand All @@ -13,6 +18,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Git
run: |
git config user.name "GitHub Bot"
Expand All @@ -22,7 +29,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "16.x"
node-version: "18.x"
cache: 'yarn'
- name: Check example apps
run: echo "EXAMPLE_APPS=$(ls ./examples | tr '\n' ',' | sed 's/,$//')" >> $GITHUB_ENV
Expand All @@ -42,8 +49,14 @@ jobs:
if: github.ref == 'refs/heads/main'
run: echo "GIT_TAG=$(git describe --exact-match --tags $(git log -n1 --pretty='%h') 2> /dev/null)" >> $GITHUB_ENV

- name: Run Build All
run: yarn build:all

# Use npx instead of yarn because yarn automatically sets NPM_* environment variables
# like NPM_CONFIG_REGISTRY so npm publish ends up ignoring the .npmrc file
# which is set up by `setup-node` action.
- name: Deploy
run: yarn nx run-many --target=deploy --all --exclude=$EXAMPLE_APPS --dry-run
run: npx nx run-many --target=deploy --all --noBuild --exclude=$EXAMPLE_APPS --dry-run
env:
EXAMPLE_APPS: ${{ env.EXAMPLE_APPS }}

Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/deploy-angular-example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Deploy Angular Example

on:
push:
branches:
- main
workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-latest
permissions:
actions: write
issues: write
pull-requests: write
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "18.x"

- name: Install dependencies
run: yarn install

- name: Build
run: yarn nx build angular

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist/examples/angular
5 changes: 5 additions & 0 deletions .github/workflows/dev-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ on:
- dev
- main

permissions:
actions: write
issues: write
pull-requests: write

jobs:
# printer:
# runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "16.x"
node-version: "18.x"
cache: 'yarn'
- name: Install NPM Dependencies
run: yarn install
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ NEAR Wallet Selector makes it easy for users to interact with your dApp by provi
- [Here Wallet](https://www.npmjs.com/package/@near-wallet-selector/here-wallet) - Mobile wallet.
- [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.
- [Finer Wallet](https://www.npmjs.com/package/@near-wallet-selector/finer-wallet) - Mobile wallet & Browser wallet.
- [Ramper Wallet](https://www.npmjs.com/package/@near-wallet-selector/ramper-wallet) - Browser wallet.

## Preview

Expand Down Expand Up @@ -70,9 +70,9 @@ yarn add \
@near-wallet-selector/default-wallets \
@near-wallet-selector/coin98-wallet \
@near-wallet-selector/opto-wallet \
@near-wallet-selector/finer-wallet \
@near-wallet-selector/neth \
@near-wallet-selector/xdefi
@near-wallet-selector/xdefi \
@near-wallet-selector/ramper-wallet

# Using NPM.
npm install \
Expand All @@ -93,9 +93,9 @@ npm install \
@near-wallet-selector/default-wallets \
@near-wallet-selector/coin98-wallet \
@near-wallet-selector/opto-wallet \
@near-wallet-selector/finer-wallet \
@near-wallet-selector/neth \
@near-wallet-selector/xdefi
@near-wallet-selector/xdefi \
@near-wallet-selector/ramper-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 All @@ -117,6 +117,7 @@ import { setupNearWallet } from "@near-wallet-selector/near-wallet";
import { setupMyNearWallet } from "@near-wallet-selector/my-near-wallet";
import { setupSender } from "@near-wallet-selector/sender";
import { setupHereWallet } from "@near-wallet-selector/here-wallet";
import { setupNearSnap } from "@near-wallet-selector/near-snap";
import { setupMathWallet } from "@near-wallet-selector/math-wallet";
import { setupNightly } from "@near-wallet-selector/nightly";
import { setupMeteorWallet } from "@near-wallet-selector/meteor-wallet";
Expand All @@ -129,9 +130,9 @@ import { setupNightlyConnect } from "@near-wallet-selector/nightly-connect";
import { setupNearFi } from "@near-wallet-selector/nearfi";
import { setupCoin98Wallet } from "@near-wallet-selector/coin98-wallet";
import { setupOptoWallet } from "@near-wallet-selector/opto-wallet";
import { setupFinerWallet } from "@near-wallet-selector/finer-wallet";
import { setupNeth } from "@near-wallet-selector/neth";
import { setupXDEFI } from "@near-wallet-selector/xdefi";
import { setupRamperWallet } from "@near-wallet-selector/ramper-wallet";

const selector = await setupWalletSelector({
network: "testnet",
Expand All @@ -150,7 +151,6 @@ const selector = await setupWalletSelector({
setupNearFi(),
setupCoin98Wallet(),
setupOptoWallet(),
setupFinerWallet(),
setupNeth(),
setupXDEFI(),
setupWalletConnect({
Expand Down
5 changes: 5 additions & 0 deletions examples/angular/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@
"glob": "**/*",
"input": "packages/neth/assets/",
"output": "assets/"
},
{
"glob": "**/*",
"input": "packages/ramper-wallet/assets/",
"output": "assets/"
}
],
"styles": ["examples/angular/src/styles.scss"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<button (click)="signOut()">Log out</button>
<button (click)="switchWallet()">Switch Wallet</button>
<button (click)="onVerifyOwner()">Verify Owner</button>
<button (click)="onSignMessage()">Sign Message</button>
<button *ngIf="accounts.length > 1" (click)="switchAccount()">
Switch Account
</button>
Expand Down
53 changes: 52 additions & 1 deletion examples/angular/src/app/components/content/content.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ import type {
CodeResult,
} from "near-api-js/lib/providers/provider";
import type { AccountState, Transaction } from "@near-wallet-selector/core";
import {
verifyFullKeyBelongsToUser,
verifySignature,
} from "@near-wallet-selector/core";

import type { Message } from "../../interfaces/message";
import type { Submitted } from "../form/form.component";
import type { Account } from "../../interfaces/account";
import type { Subscription } from "rxjs";
import { distinctUntilChanged, map } from "rxjs";
import { WalletSelectorModal } from "@near-wallet-selector/modal-ui";
import { WalletSelectorModal } from "@near-wallet-selector/modal-ui-js";
import { CONTRACT_ID } from "../../../constants";
import { WalletSelector } from "@near-wallet-selector/core";
import type { GetAccountBalanceProps } from "../../interfaces/account-balance";
Expand Down Expand Up @@ -161,6 +165,53 @@ export class ContentComponent implements OnInit, OnDestroy {
}
}

async onSignMessage() {
const wallet = await this.selector.wallet();
const message = "test message to sign";
const nonce = Buffer.from(Array.from(Array(32).keys()));
const recipient = "guest-book.testnet";

try {
const signedMessage = await wallet.signMessage({
message,
nonce,
recipient,
});
if (signedMessage) {
const verifiedSignature = verifySignature({
message,
nonce,
recipient,
publicKey: signedMessage.publicKey,
signature: signedMessage.signature,
});
const verifiedFullKeyBelongsToUser = await verifyFullKeyBelongsToUser({
publicKey: signedMessage.publicKey,
accountId: signedMessage.accountId,
network: this.selector.options.network,
});

if (verifiedFullKeyBelongsToUser && verifiedSignature) {
alert(
`Successfully verify signed message: '${message}': \n ${JSON.stringify(
signedMessage
)}`
);
} else {
alert(
`Failed to verify signed message '${message}': \n ${JSON.stringify(
signedMessage
)}`
);
}
}
} catch (err) {
const errMsg =
err instanceof Error ? err.message : "Something went wrong";
alert(errMsg);
}
}

subscribeToEvents() {
this.subscription = this.selector.store.observable
.pipe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { setupNightlyConnect } from "@near-wallet-selector/nightly-connect";
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 { setupLedger } from "@near-wallet-selector/ledger";

declare global {
Expand Down Expand Up @@ -89,6 +90,7 @@ export class WalletSelectorExportComponent implements OnInit {
icon: "https://near.org/wp-content/uploads/2020/09/cropped-favicon-192x192.png",
},
}),
setupRamperWallet(),
],
});
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { setupWalletConnect } from "@near-wallet-selector/wallet-connect";
import { setupNightlyConnect } from "@near-wallet-selector/nightly-connect";
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 { CONTRACT_ID } from "../../../constants";

Expand Down Expand Up @@ -75,7 +76,7 @@ export class WalletSelectorComponent implements OnInit {
setupOptoWallet(),
setupFinerWallet(),
setupWalletConnect({
projectId: "c4f79cc...",
projectId: "c8cb6204543639c31aef44ea4837a554", // Replace this with your own projectId form WalletConnect.
metadata: {
name: "NEAR Wallet Selector",
description: "Example dApp used by NEAR Wallet Selector",
Expand All @@ -92,6 +93,7 @@ export class WalletSelectorComponent implements OnInit {
icon: "https://near.org/wp-content/uploads/2020/09/cropped-favicon-192x192.png",
},
}),
setupRamperWallet(),
],
});

Expand Down
2 changes: 1 addition & 1 deletion examples/angular/src/polyfills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import "zone.js"; // Included with Angular CLI.
// eslint-disable-next-line @typescript-eslint/no-var-requires
global.Buffer = global.Buffer || require("buffer").Buffer;

(window as any).process = { env: {} };
(window as any).process = { env: {}, version: "" };

/***************************************************************************************************
* APPLICATION IMPORTS
Expand Down
Loading

0 comments on commit 8433139

Please sign in to comment.