Skip to content

Commit

Permalink
Merge pull request #1269 from near/dev
Browse files Browse the repository at this point in the history
v8.9.15 Release (dev → main)
  • Loading branch information
gtsonevv authored Dec 13, 2024
2 parents a63530c + b67dbba commit f7ca952
Show file tree
Hide file tree
Showing 39 changed files with 108 additions and 234 deletions.
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "near-wallet-selector",
"version": "8.9.14",
"version": "8.9.15",
"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 @@ -101,15 +101,14 @@
"@near-snap/sdk": "0.6.0",
"@noble/ciphers": "0.5.3",
"@noble/hashes": "1.4.0",
"@peersyst/near-mobile-signer": "1.1.0",
"@peersyst/near-mobile-signer": "1.1.1",
"@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.3.0",
"big.js": "6.2.2",
"borsh": "0.7.0",
"borsh": "1.0.0",
"browserify-fs": "1.0.0",
"bs58": "5.0.0",
"buffer": "6.0.3",
Expand Down Expand Up @@ -223,4 +222,4 @@
"webpack": "5.75.0",
"webpack-merge": "5.8.0"
}
}
}
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.14",
"version": "8.9.15",
"description": "This is the Export Selector UI package for NEAR Wallet Selector.",
"keywords": [
"near",
Expand Down
2 changes: 1 addition & 1 deletion packages/arepa-wallet/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@near-wallet-selector/arepa-wallet",
"version": "8.9.14",
"version": "8.9.15",
"description": "Arepa Wallet 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.14",
"version": "8.9.15",
"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.14",
"version": "8.9.15",
"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.14",
"version": "8.9.15",
"description": "Coin 98 wallet package for NEAR Wallet Selector.",
"keywords": [
"near",
Expand Down
7 changes: 3 additions & 4 deletions 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.14",
"version": "8.9.15",
"description": "This is the core package for NEAR Wallet Selector.",
"keywords": [
"near",
Expand All @@ -20,7 +20,6 @@
},
"homepage": "https://github.com/near/wallet-selector/tree/main/packages/core",
"peerDependencies": {
"near-api-js": "4.0.3",
"@near-js/providers": "latest"
"near-api-js": "4.0.3"
}
}
}
31 changes: 10 additions & 21 deletions packages/core/src/lib/helpers/verify-signature/payload.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { SignMessageParams } from "../../wallet";
import type { Schema } from "borsh";
import { serialize } from "borsh";

export class Payload {
Expand All @@ -21,27 +22,15 @@ export class Payload {
}
}

export const payloadSchema = new Map([
[
Payload,
{
kind: "struct",
fields: [
["tag", "u32"],
["message", "string"],
["nonce", [32]],
["recipient", "string"],
[
"callbackUrl",
{
kind: "option",
type: "string",
},
],
],
},
],
]);
export const payloadSchema: Schema = {
struct: {
tag: "u32",
message: "string",
nonce: { array: { type: "u8", len: 32 } },
recipient: "string",
callbackUrl: { option: "string" },
},
};

export const serializeNep413 = (
signMessageParams: SignMessageParams
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/lib/options.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe("getNetworkPreset", () => {
nodeUrl: "https://rpc.mainnet.near.org",
helperUrl: "https://helper.mainnet.near.org",
explorerUrl: "https://nearblocks.io",
indexerUrl: "https://api.kitwallet.app",
indexerUrl: "https://api.fastnear.com/v0",
});
});

Expand All @@ -29,7 +29,7 @@ describe("getNetworkPreset", () => {
nodeUrl: "https://rpc1.mainnet.near.org",
helperUrl: "https://helper.mainnet.near.org",
explorerUrl: "https://nearblocks.io",
indexerUrl: "https://api.kitwallet.app",
indexerUrl: "https://api.fastnear.com/v0",
});
});

Expand All @@ -42,7 +42,7 @@ describe("getNetworkPreset", () => {
nodeUrl: "https://rpc.testnet.near.org",
helperUrl: "https://helper.testnet.near.org",
explorerUrl: "https://testnet.nearblocks.io",
indexerUrl: "https://testnet-api.kitwallet.app",
indexerUrl: "https://test.api.fastnear.com/v0",
});
});

Expand All @@ -60,7 +60,7 @@ describe("getNetworkPreset", () => {
nodeUrl: "https://rpc1.testnet.near.org",
helperUrl: "https://helper.testnet.near.org",
explorerUrl: "https://testnet.nearblocks.io",
indexerUrl: "https://testnet-api.kitwallet.app",
indexerUrl: "https://test.api.fastnear.com/v0",
});
});
});
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/lib/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ export const getNetworkPreset = (
nodeUrl: fallbackRpcUrls?.[0] || "https://rpc.mainnet.near.org",
helperUrl: "https://helper.mainnet.near.org",
explorerUrl: "https://nearblocks.io",
indexerUrl: "https://api.kitwallet.app",
indexerUrl: "https://api.fastnear.com/v0",
};
case "testnet":
return {
networkId,
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",
indexerUrl: "https://test.api.fastnear.com/v0",
};
default:
throw Error(`Failed to find config for: '${networkId}'`);
Expand Down
10 changes: 6 additions & 4 deletions packages/core/src/lib/wallet-selector.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { setupWalletSelector } from "./wallet-selector";
import { FailoverRpcProvider } from "@near-js/providers";
import { getNetworkPreset } from "./options";
import { JsonRpcProvider } from "near-api-js/lib/providers";
import {
JsonRpcProvider,
FailoverRpcProvider,
} from "near-api-js/lib/providers";
import type { Network } from "./options.types";
import type { Store } from "./store.types";
import type { WalletModuleFactory } from "./wallet";
Expand Down Expand Up @@ -52,8 +54,8 @@ jest.mock("./store", () => {
};
});

jest.mock("@near-js/providers", () => {
const originalModule = jest.requireActual("@near-js/providers");
jest.mock("near-api-js/lib/providers", () => {
const originalModule = jest.requireActual("near-api-js/lib/providers");
return {
...originalModule,
FailoverRpcProvider: jest.fn(),
Expand Down
2 changes: 1 addition & 1 deletion packages/ethereum-wallets/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@near-wallet-selector/ethereum-wallets",
"version": "8.9.14",
"version": "8.9.15",
"description": "Ethereum wallets package for NEAR Wallet Selector.",
"keywords": [
"near",
Expand Down
8 changes: 7 additions & 1 deletion packages/ethereum-wallets/src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ const EthereumWallets: WalletBehaviourFactory<
options.network.networkId,
devMode ? address + "." + devModeAccount : address
);
if (!keyPair) {
if (!keyPair && !skipSignInAccessKey) {
try {
wagmiCore!.disconnect(wagmiConfig);
} catch (error) {
Expand Down Expand Up @@ -591,6 +591,7 @@ const EthereumWallets: WalletBehaviourFactory<
for (const [index, tx] of txs.entries()) {
let txHash;
let txError: string | null = null;
let showDetails = false;
while (!txHash) {
try {
await (() => {
Expand All @@ -599,13 +600,18 @@ const EthereumWallets: WalletBehaviourFactory<
selectedIndex: index,
ethTxHashes,
error: txError,
showDetails,
onShowDetails: (state: boolean) => {
showDetails = state;
},
onConfirm: async () => {
try {
txError = null;
renderTxs({
selectedIndex: index,
ethTxHashes,
error: txError,
showDetails,
});
txHash = await executeTransaction({
tx,
Expand Down
20 changes: 20 additions & 0 deletions packages/ethereum-wallets/src/lib/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,15 @@ export function createTxModal({
selectedIndex,
ethTxHashes,
error,
showDetails,
onShowDetails,
onConfirm,
}: {
selectedIndex: number;
ethTxHashes: Array<string>;
error?: string | null;
onShowDetails?: (state: boolean) => void;
showDetails?: boolean;
onConfirm?: () => void;
}) => {
const container = document.querySelector(
Expand Down Expand Up @@ -339,6 +343,16 @@ export function createTxModal({
".ethereum-wallet-txs-details"
) as HTMLElement | null;

if (detailsContainer && toggleButton) {
if (showDetails) {
detailsContainer.style.display = "block";
toggleButton.textContent = "Hide details";
} else {
detailsContainer.style.display = "none";
toggleButton.textContent = "Show details";
}
}

toggleButton?.addEventListener("click", () => {
if (!detailsContainer || !toggleButton) {
return;
Expand All @@ -350,9 +364,15 @@ export function createTxModal({
) {
detailsContainer.style.display = "block";
toggleButton.textContent = "Hide details";
if (onShowDetails) {
onShowDetails(true);
}
} else {
detailsContainer.style.display = "none";
toggleButton.textContent = "Show details";
if (onShowDetails) {
onShowDetails(false);
}
}
});
};
Expand Down
2 changes: 1 addition & 1 deletion packages/here-wallet/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@near-wallet-selector/here-wallet",
"version": "8.9.14",
"version": "8.9.15",
"description": "Here wallet package for NEAR Wallet Selector.",
"keywords": [
"near",
Expand Down
2 changes: 1 addition & 1 deletion packages/ledger/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@near-wallet-selector/ledger",
"version": "8.9.14",
"version": "8.9.15",
"description": "Ledger package for NEAR Wallet Selector.",
"keywords": [
"near",
Expand Down
2 changes: 1 addition & 1 deletion packages/math-wallet/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@near-wallet-selector/math-wallet",
"version": "8.9.14",
"version": "8.9.15",
"description": "Math wallet package for NEAR Wallet Selector.",
"keywords": [
"near",
Expand Down
2 changes: 1 addition & 1 deletion packages/meteor-wallet/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@near-wallet-selector/meteor-wallet",
"version": "8.9.14",
"version": "8.9.15",
"description": "Meteor wallet package for NEAR Wallet Selector.",
"keywords": [
"near",
Expand Down
2 changes: 1 addition & 1 deletion packages/mintbase-wallet/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@near-wallet-selector/mintbase-wallet",
"version": "8.9.14",
"version": "8.9.15",
"description": "Mintbase wallet package for NEAR Wallet Selector.",
"keywords": [
"near",
Expand Down
2 changes: 1 addition & 1 deletion packages/modal-ui-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@near-wallet-selector/modal-ui-js",
"version": "8.9.14",
"version": "8.9.15",
"description": "Modal UI package for NEAR wallet Selector",
"keywords": [
"near",
Expand Down
16 changes: 7 additions & 9 deletions packages/modal-ui-js/src/lib/render-modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,19 @@ const getAccountIds = async (publicKey: string): Promise<Array<string>> => {
return [];
}

const response = await fetch(
`${modalState.selector.options.network.indexerUrl}/publicKey/ed25519:${publicKey}/accounts`
);
const url = `${modalState.selector.options.network.indexerUrl}/public_key/ed25519:${publicKey}`;
const response = await fetch(url);

if (!response.ok) {
throw new Error("Failed to get account id from public key");
throw new Error("Failed to get account ID from public key");
}

const accountIds = await response.json();
const jsonResponse: { account_ids: Array<string>; public_key: string } =
await response.json();

if (!Array.isArray(accountIds) || !accountIds.length) {
return [];
}
const { account_ids: accountIds } = jsonResponse;

return accountIds;
return Array.isArray(accountIds) ? accountIds : [];
};

export const resolveAccounts = async (
Expand Down
2 changes: 1 addition & 1 deletion packages/modal-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@near-wallet-selector/modal-ui",
"version": "8.9.14",
"version": "8.9.15",
"description": "Modal UI package for NEAR wallet Selector",
"keywords": [
"near",
Expand Down
Loading

0 comments on commit f7ca952

Please sign in to comment.