Skip to content

Commit

Permalink
Merge pull request #1160 from near/dev
Browse files Browse the repository at this point in the history
v8.9.12 Release (dev → main)
  • Loading branch information
Pavel Ivanov authored Aug 8, 2024
2 parents c1edf6c + b3fee4b commit c083610
Show file tree
Hide file tree
Showing 59 changed files with 1,080 additions and 523 deletions.
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "near-wallet-selector",
"version": "8.9.11",
"version": "8.9.12",
"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 Down Expand Up @@ -91,23 +91,23 @@
"@angular/platform-browser-dynamic": "16.1.9",
"@angular/router": "16.1.9",
"@here-wallet/core": "3.3.1",
"@jscutlery/semver": "3.1.0",
"@jscutlery/semver": "5.2.2",
"@ledgerhq/hw-transport": "6.30.3",
"@ledgerhq/hw-transport-webhid": "6.28.6",
"@ledgerhq/hw-transport-webhid": "6.29.2",
"@metamask/detect-provider": "2.0.0",
"@meteorwallet/sdk": "1.0.9",
"@mintbase-js/wallet": "0.6.0-beta.10",
"@near-snap/sdk": "0.6.0",
"@noble/ciphers": "0.5.3",
"@noble/hashes": "1.4.0",
"@peersyst/near-mobile-signer": "1.0.12",
"@peersyst/near-mobile-signer": "1.1.0",
"@ramper/near": "0.0.30",
"@tanstack/react-query": "5.24.8",
"@walletconnect/modal": "2.6.2",
"@walletconnect/sign-client": "2.13.0",
"@web3modal/wagmi": "5.0.6",
"better-sqlite3": "11.1.2",
"big.js": "6.1.1",
"big.js": "6.2.1",
"borsh": "0.7.0",
"browserify-fs": "1.0.0",
"bs58": "5.0.0",
Expand All @@ -125,12 +125,12 @@
"qrcode": "1.5.3",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-qr-code": "2.0.12",
"react-qr-code": "2.0.15",
"regenerator-runtime": "0.14.1",
"rxjs": "7.8.1",
"stream-browserify": "3.0.0",
"stream-http": "3.2.0",
"tslib": "2.6.2",
"tslib": "2.6.3",
"url": "0.11.0",
"viem": "2.16.2",
"wagmi": "2.10.9",
Expand Down Expand Up @@ -179,8 +179,8 @@
"@types/react": "18.0.25",
"@types/react-dom": "18.0.9",
"@types/regenerator-runtime": "0.13.1",
"@types/w3c-web-hid": "1.0.2",
"@types/w3c-web-usb": "1.0.5",
"@types/w3c-web-hid": "1.0.3",
"@types/w3c-web-usb": "1.0.6",
"@typescript-eslint/eslint-plugin": "5.58.0",
"@typescript-eslint/parser": "5.58.0",
"babel-jest": "29.4.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/account-export/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@near-wallet-selector/account-export",
"version": "8.9.11",
"version": "8.9.12",
"description": "This is the Export Selector UI package for NEAR Wallet Selector.",
"keywords": [
"near",
Expand Down
2 changes: 1 addition & 1 deletion packages/bitget-wallet/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@near-wallet-selector/bitget-wallet",
"version": "8.9.11",
"version": "8.9.12",
"description": "Bitget wallet package for NEAR Wallet Selector.",
"keywords": [
"near",
Expand Down
2 changes: 1 addition & 1 deletion packages/bitte-wallet/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@near-wallet-selector/bitte-wallet",
"version": "8.9.11",
"version": "8.9.12",
"description": "Bitte wallet package for NEAR Wallet Selector.",
"keywords": [
"near",
Expand Down
2 changes: 1 addition & 1 deletion packages/coin98-wallet/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@near-wallet-selector/coin98-wallet",
"version": "8.9.11",
"version": "8.9.12",
"description": "Coin 98 wallet package for NEAR Wallet Selector.",
"keywords": [
"near",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@near-wallet-selector/core",
"version": "8.9.11",
"version": "8.9.12",
"description": "This is the core package for NEAR Wallet Selector.",
"keywords": [
"near",
Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/lib/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
export const PACKAGE_NAME = "near-wallet-selector";
export const RECENTLY_SIGNED_IN_WALLETS = "recentlySignedInWallets";
export const REMEMBER_RECENT_WALLETS = "rememberRecentWallets";
export const REMEMBER_RECENT_WALLETS_STATE = {
ENABLED: "enabled",
DISABLED: "disabled",
};

export const CONTRACT = "contract";
export const PENDING_CONTRACT = "contract:pending";
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/lib/locale/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"useAWallet": "استخدم محفظة لتأمين وإدارة أصول نير الخاصة بك، وادخل لأي تطبيق يستخدم نير دون الحاجة إلى اسم المستخدم وكلمةالمرور",
"connectionFailed": "اتصال فاشل",
"connectionSuccessful": "اتصال ناجح",
"rememberWallet": "تذكر المحافظ",
"connected": "متصل",
"connectingTo": "جاري الاتصال ب",
"connectingMessage": {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/lib/locale/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"useAWallet": "Използвайте портфейла, за да защитите и управлявате активите си на NEAR както и да използвате всяко приложение на NEAR без нужда от потребителски имена и пароли.",
"connectionFailed": "Свързването неуспешно",
"connectionSuccessful": "Свързването успешно",
"rememberWallet": "Запази портфейлите",
"connected": "Свързан",
"connectingTo": "Свързване към",
"connectingMessage": {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/lib/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"useAWallet": "Use a wallet to secure and manage your NEAR assets, and to log in to any NEAR app without the need for usernames and passwords.",
"connectionFailed": "Connection Failed",
"connectionSuccessful": "Connection Successful",
"rememberWallet": "Remember wallets",
"connected": "Connected",
"connectingTo": "Connecting to",
"connectingMessage": {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/lib/locale/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"useAWallet": "Usa tu Billetera para resguardar y administrar tus activos en NEAR, e Iniciar sesión en cualquier aplicacion NEAR sin la necesidad de nombres de usuarios y contraseñas",
"connectionFailed": "Conexión Fallida",
"connectionSuccessful": "Conexión Existosa",
"rememberWallet": "Recordar las carteras",
"connected": "Conectado",
"connectingTo": "Conectando a ",
"connectingMessage": {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/lib/locale/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"useAWallet": "अपनी NEAR संपत्तियों को सुरक्षित और प्रबंधित करने के लिए वॉलेट का उपयोग करें और किसी भी NEAR ऐप (app) में लॉग इन करें, किसी उपयोगकर्ता (user) नाम और पासवर्ड की आवश्यकता नहीं है।",
"connectionFailed": "कनेक्शन विफल|",
"connectionSuccessful": "कनेक्शन सफल|",
"rememberWallet": "वॉलेटों को याद रखें",
"connected": "वॉलेट जुड़ गया|",
"connectingTo": "वॉलेट जुड़ रहा हे|",
"connectingMessage": {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/lib/locale/hr.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"useAWallet": "Koristite crypto novčanik da biste osigurali i upravljali svojom NEAR imovinom, te se prijavite u bilo koju NEAR aplikaciju bez korisničkog imena i lozinke.",
"connectionFailed": "Neuspješno povezivanje.",
"connectionSuccessful": "Uspješno povezivanje.",
"rememberWallet": "Zapamti novčanike",
"connected": "Povezano.",
"connectingTo": "Povezivanje u tijeku",
"connectingMessage": {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/lib/locale/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"useAWallet": "지갑을 사용하여 NEAR 자산을 보호·관리하고, 아이디와 비밀번호 없이 NEAR 앱에 로그인할 수 있습니다.",
"connectionFailed": "연결 실패",
"connectionSuccessful": "연결 성공",
"rememberWallet": "지갑들 기억하기",
"connected": "Connected",
"connectingTo": "연결 중: ",
"connectingMessage": {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/lib/locale/mk.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"useAWallet": "Користете паричник за да ги заштитите и управувате вашите NEAR средства и да се најавите на која било NEAR апликација без потреба од кориснички имиња и лозинки.",
"connectionFailed": "Поврзувањето не беше успешно.",
"connectionSuccessful": "Успешно поврзување.",
"rememberWallet": "Запомни паричници",
"connected": "Поврзано.",
"connectingTo": "Поврзување со",
"connectingMessage": {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/lib/locale/sl.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"useAWallet": "Uporabite denarnico, da bi zavarovali in upravljali s svoja NEAR digitalna sredstva, in se prijavite v katero koli aplikacijo ekosistema NEAR",
"connectionFailed": "Povezava ni bila uspešna.",
"connectionSuccessful": "Povezava je bila uspešna.",
"rememberWallet": "Zapomni si denarnice",
"connected": "Vaša denarnica je povezana.",
"connectingTo": "Povezovanje z",
"connectingMessage": {
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/lib/locale/sr.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"useAWallet": "Користите новчаник да обезбедите и управљате својим NEAR средствима и да се пријавите у било коју апликацију NEAR без потребе за корисничким именима и лозинкама.",
"connectionFailed": "Веза није успостављена.",
"connectionSuccessful": "Веза је успела.",
"rememberWallet": "Запамти новчанике",
"connected": "Повезан.",
"connectingTo": "Повезивање на",
"connectingMessage": {
Expand Down Expand Up @@ -103,4 +104,4 @@
}
}
}
}
}
1 change: 1 addition & 0 deletions packages/core/src/lib/locale/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"useAWallet": "Sử dụng ví để bảo mật và quản lý tài sản trên NEAR của bạn và đăng nhập vào bất kỳ ứng dụng NEAR nào, không cần tên người dùng và mật khẩu.",
"connectionFailed": "Kết nối thất bại",
"connectionSuccessful": "Kết nối thành công",
"rememberWallet": "Ghi nhớ lựa chọn ví",
"connected": "Đã kết nối",
"connectingTo": "Đang kết nối tới",
"connectingMessage": {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/lib/locale/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"useAWallet": "使用钱包来保护和管理你的 NEAR 资产,无需用户名和密码即可登录任何 NEAR 应用",
"connectionFailed": "连接失败",
"connectionSuccessful": "连接成功",
"rememberWallet": "记住钱包选择",
"connected": "已连接",
"connectingTo": "正在连接"
},
Expand Down
40 changes: 38 additions & 2 deletions packages/core/src/lib/options.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getNetworkPreset, resolveNetwork } from "./options";
import type { NetworkId, Network } from "./options.types";

describe("getNetworkPreset", () => {
it("returns the correct config for 'mainnet'", () => {
it("returns the correct config for 'mainnet' without fallbackRpcUrls", () => {
const networkId: NetworkId = "mainnet";
const network = getNetworkPreset(networkId);

Expand All @@ -15,7 +15,25 @@ describe("getNetworkPreset", () => {
});
});

it("returns the correct config for 'testnet'", () => {
it("returns the correct config for 'mainnet' with fallbackRpcUrls", () => {
const networkId: NetworkId = "mainnet";
const fallbackRpcUrls: Array<string> = [
"https://rpc1.mainnet.near.org",
"https://rpc2.mainnet.near.org",
"https://rpc3.mainnet.near.org",
];
const network = getNetworkPreset(networkId, fallbackRpcUrls);

expect(network).toEqual({
networkId,
nodeUrl: "https://rpc1.mainnet.near.org",
helperUrl: "https://helper.mainnet.near.org",
explorerUrl: "https://nearblocks.io",
indexerUrl: "https://api.kitwallet.app",
});
});

it("returns the correct config for 'testnet' without fallbackRpcUrls", () => {
const networkId: NetworkId = "testnet";
const network = getNetworkPreset(networkId);

Expand All @@ -27,6 +45,24 @@ describe("getNetworkPreset", () => {
indexerUrl: "https://testnet-api.kitwallet.app",
});
});

it("returns the correct config for 'testnet' with fallbackRpcUrls", () => {
const networkId: NetworkId = "testnet";
const fallbackRpcUrls: Array<string> = [
"https://rpc1.testnet.near.org",
"https://rpc2.testnet.near.org",
"https://rpc3.testnet.near.org",
];
const network = getNetworkPreset(networkId, fallbackRpcUrls);

expect(network).toEqual({
networkId,
nodeUrl: "https://rpc1.testnet.near.org",
helperUrl: "https://helper.testnet.near.org",
explorerUrl: "https://testnet.nearblocks.io",
indexerUrl: "https://testnet-api.kitwallet.app",
});
});
});

describe("resolveNetwork", () => {
Expand Down
9 changes: 6 additions & 3 deletions packages/core/src/lib/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@ import type { WalletSelectorParams } from "./wallet-selector.types";
import type { Options, Network, NetworkId } from "./options.types";
import { WebStorageService } from "./services";

export const getNetworkPreset = (networkId: NetworkId): Network => {
export const getNetworkPreset = (
networkId: NetworkId,
fallbackRpcUrls?: Array<string>
): Network => {
switch (networkId) {
case "mainnet":
return {
networkId,
nodeUrl: "https://rpc.mainnet.near.org",
nodeUrl: fallbackRpcUrls?.[0] || "https://rpc.mainnet.near.org",
helperUrl: "https://helper.mainnet.near.org",
explorerUrl: "https://nearblocks.io",
indexerUrl: "https://api.kitwallet.app",
};
case "testnet":
return {
networkId,
nodeUrl: "https://rpc.testnet.near.org",
nodeUrl: fallbackRpcUrls?.[0] || "https://rpc.testnet.near.org",
helperUrl: "https://helper.testnet.near.org",
explorerUrl: "https://testnet.nearblocks.io",
indexerUrl: "https://testnet-api.kitwallet.app",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const setup = (url: string) => {

return {
provider,
service: new Provider(url),
service: new Provider([url]),
};
};

Expand Down
29 changes: 23 additions & 6 deletions packages/core/src/lib/services/provider/provider.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,34 @@ import type {
AccessKeyView,
BlockReference,
QueryResponseKind,
RpcQueryRequest,
} from "near-api-js/lib/providers/provider";
import type { SignedTransaction } from "near-api-js/lib/transaction";
import type {
ProviderService,
QueryParams,
ViewAccessKeyParams,
} from "./provider.service.types";
import { JsonRpcProvider } from "near-api-js/lib/providers";
import type { SignedTransaction } from "near-api-js/lib/transaction";

export class Provider implements ProviderService {
private provider: nearAPI.providers.JsonRpcProvider;
private provider: nearAPI.providers.FailoverRpcProvider;

constructor(url: string) {
this.provider = new nearAPI.providers.JsonRpcProvider({ url });
constructor(urls: Array<string>) {
this.provider = new nearAPI.providers.FailoverRpcProvider(
this.urlsToProviders(urls)
);
}

query<Response extends QueryResponseKind>(params: QueryParams) {
return this.provider.query<Response>(params);
query<Response extends QueryResponseKind>(
paramsOrPath: QueryParams | RpcQueryRequest | string,
data?: string
): Promise<Response> {
if (typeof paramsOrPath === "string" && data !== undefined) {
return this.provider.query<Response>(paramsOrPath, data);
} else {
return this.provider.query<Response>(paramsOrPath as RpcQueryRequest);
}
}

viewAccessKey({ accountId, publicKey }: ViewAccessKeyParams) {
Expand All @@ -38,4 +49,10 @@ export class Provider implements ProviderService {
sendTransaction(signedTransaction: SignedTransaction) {
return this.provider.sendTransaction(signedTransaction);
}

private urlsToProviders(urls: Array<string>) {
return urls && urls.length > 0
? urls.map((url) => new JsonRpcProvider({ url }))
: [];
}
}
Loading

0 comments on commit c083610

Please sign in to comment.