Skip to content

Commit

Permalink
Merge pull request #767 from near/dev
Browse files Browse the repository at this point in the history
v7.9.3 Release (dev -> main)
  • Loading branch information
kujtimprenkuSQA authored Apr 6, 2023
2 parents bfd3754 + 28774c2 commit 13edffd
Show file tree
Hide file tree
Showing 73 changed files with 1,657 additions and 364 deletions.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "near-wallet-selector",
"version": "7.9.2",
"version": "7.9.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 Down Expand Up @@ -84,15 +84,15 @@
"@angular/platform-browser-dynamic": "~14.0.0",
"@angular/router": "~14.0.0",
"@here-wallet/core": "^1.4.0",
"@jscutlery/semver": "^2.29.3",
"@jscutlery/semver": "^2.30.1",
"@ledgerhq/hw-transport": "6.27.1",
"@ledgerhq/hw-transport-webhid": "6.27.1",
"@metamask/detect-provider": "^2.0.0",
"@meteorwallet/sdk": "^0.6.0",
"@nightlylabs/connect-near": "0.0.15",
"@walletconnect/qrcode-modal": "2.0.0-alpha.20",
"@walletconnect/sign-client": "2.1.4",
"better-sqlite3": "^8.1.0",
"@walletconnect/sign-client": "2.5.2",
"@web3modal/standalone": "^2.2.2",
"better-sqlite3": "^8.2.0",
"big.js": "^6.1.1",
"bn.js": "^5.2.0",
"bs58": "^5.0.0",
Expand All @@ -105,7 +105,7 @@
"near-api-js": "^1.1.0",
"near-seed-phrase": "^0.2.0",
"next": "12.2.3",
"ngx-deploy-npm": "^4.3.1",
"ngx-deploy-npm": "^4.3.10",
"qrcode": "^1.5.1",
"react": "18.2.0",
"react-dom": "18.2.0",
Expand Down Expand Up @@ -160,7 +160,7 @@
"@types/w3c-web-usb": "^1.0.5",
"@typescript-eslint/eslint-plugin": "5.13.0",
"@typescript-eslint/parser": "5.13.0",
"@walletconnect/types": "^2.1.4",
"@walletconnect/types": "^2.5.2",
"babel-jest": "27.2.3",
"cypress": "^9.1.0",
"eslint": "~8.15.0",
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": "7.9.2",
"version": "7.9.3",
"description": "This is the Export Selector UI package for NEAR Wallet Selector.",
"keywords": [
"near",
Expand Down
12 changes: 7 additions & 5 deletions packages/account-export/src/lib/components/ExportAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {
InjectedWalletMetadata,
} from "@near-wallet-selector/core";

import { utils, providers } from "near-api-js";
import * as nearAPI from "near-api-js";
import type {
FunctionCallPermissionView,
AccessKeyView,
Expand Down Expand Up @@ -78,7 +78,7 @@ const permissionToType = (
};

interface getAccountTypeProps {
provider: providers.Provider;
provider: nearAPI.providers.Provider;
accountId: string;
publicKey: string;
}
Expand All @@ -103,7 +103,7 @@ const getAccountType = async ({
};

interface getAccountBalanceProps {
provider: providers.Provider;
provider: nearAPI.providers.Provider;
accountId: string;
}

Expand Down Expand Up @@ -183,15 +183,17 @@ export const ExportAccount: React.FC<ExportAccountProps> = ({
}, [module?.metadata.name, alertMessage]);

const { network } = selector.options;
const provider = new providers.JsonRpcProvider({ url: network.nodeUrl });
const provider = new nearAPI.providers.JsonRpcProvider({
url: network.nodeUrl,
});
const [hasCopied, setHasCopied] = useState(false);

useEffect(() => {
const initialize = async () => {
setIsLoading(true);
const accountsWithDetails = await Promise.all(
accounts.map(async ({ accountId, privateKey }) => {
const keyPair = utils.KeyPair.fromString(privateKey);
const keyPair = nearAPI.utils.KeyPair.fromString(privateKey);
const { type } = await getAccountType({
provider,
accountId,
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": "7.9.2",
"version": "7.9.3",
"description": "Coin 98 wallet package for NEAR Wallet Selector.",
"keywords": [
"near",
Expand Down
132 changes: 132 additions & 0 deletions packages/coin98-wallet/src/lib/coin98-wallet.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/* eslint-disable @nrwl/nx/enforce-module-boundaries */
import { mock } from "jest-mock-extended";
import { mockWallet } from "../../../core/src/lib/testUtils";

import type { MockWalletDependencies } from "../../../core/src/lib/testUtils";
import type { InjectedWallet } from "../../../core/src/lib/wallet";
import { setupCoin98Wallet } from "./coin98-wallet";
import type { Signer } from "near-api-js/lib/signer";

const accountId = "amirsaran.testnet";
const publicKey = "GF7tLvSzcxX4EtrMFtGvGTb2yUj2DhL8hWzc97BwUkyC";

const mockCoin98WalletOnWindow = () => {
window.coin98 = {
near: {
account: "",
signer: mock<Signer>({
createKey: jest.fn(),
signMessage: jest.fn().mockReturnValue({
signature: Buffer.from([
86, 38, 222, 143, 115, 251, 107, 14, 115, 59, 92, 98, 66, 174, 173,
124, 209, 189, 191, 180, 89, 25, 125, 254, 97, 240, 178, 98, 65, 70,
238, 108, 105, 122, 165, 249, 193, 70, 118, 194, 126, 218, 117, 100,
250, 124, 202, 161, 173, 12, 232, 146, 105, 194, 138, 35, 207, 53,
84, 218, 45, 220, 10, 4,
]),
publicKey,
}),
getPublicKey: jest.fn().mockReturnValue(publicKey),
}),
connect: jest.fn(async () => {
window.coin98.near.account = accountId;
return "";
}),
disconnect: jest.fn(),
},
};

return window.coin98;
};

const createCoin98Wallet = async (deps: MockWalletDependencies = {}) => {
const injectedCoin98Wallet = mockCoin98WalletOnWindow();
const { wallet } = await mockWallet<InjectedWallet>(
setupCoin98Wallet(),
deps
);

return {
wallet,
injectedCoin98Wallet,
};
};

afterEach(() => {
jest.resetModules();
});

describe("signIn", () => {
it("sign into coin98 wallet", async () => {
const { wallet, injectedCoin98Wallet } = await createCoin98Wallet();

await wallet.signIn({ contractId: "test.testnet" });

expect(injectedCoin98Wallet.near.connect).toHaveBeenCalled();
});
});

describe("signOut", () => {
it("sign out of coin98 wallet", async () => {
const { wallet, injectedCoin98Wallet } = await createCoin98Wallet();

await wallet.signIn({ contractId: "test.testnet" });
await wallet.signOut();

expect(injectedCoin98Wallet.near.disconnect).toHaveBeenCalled();
});
});

describe("getAccounts", () => {
it("returns array of accounts", async () => {
const { wallet, injectedCoin98Wallet } = await createCoin98Wallet();

await wallet.signIn({ contractId: "test.testnet" });
const result = await wallet.getAccounts();

expect(injectedCoin98Wallet.near.signer.getPublicKey).toHaveBeenCalled();
expect(result).toEqual([{ accountId, publicKey }]);
});
});

describe("signAndSendTransaction", () => {
it("sign transaction in coin98", async () => {
const { wallet, injectedCoin98Wallet } = await createCoin98Wallet();

await wallet.signIn({ contractId: "test.testnet" });
await wallet.signAndSendTransaction({
signerId: accountId,
receiverId: "test.testnet",
actions: [],
});

expect(injectedCoin98Wallet.near.signer.signMessage).toHaveBeenCalled();
});
});

describe("signAndSendTransactions", () => {
it("sign transactions in coin98", async () => {
const { wallet, injectedCoin98Wallet } = await createCoin98Wallet();

const transactions = [
{
signerId: accountId,
receiverId: "test.testnet",
actions: [],
},
{
signerId: accountId,
receiverId: "test.testnet",
actions: [],
},
];

await wallet.signIn({ contractId: "test.testnet" });
const result = await wallet.signAndSendTransactions({
transactions,
});

expect(injectedCoin98Wallet.near.signer.signMessage).toHaveBeenCalled();
expect(result.length).toEqual(transactions.length);
});
});
14 changes: 7 additions & 7 deletions packages/coin98-wallet/src/lib/coin98-wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ const Coin98Wallet: WalletBehaviourFactory<InjectedWallet> = async ({
return [];
}

const publicKey = await _state.wallet.near.signer.getPublicKey(
accountId,
options.network.networkId
);

return [
{
accountId: _state.wallet.near.account,
publicKey: (
await _state.wallet.near.signer.getPublicKey(
accountId,
options.network.networkId
)
).toString(),
accountId,
publicKey: publicKey ? publicKey.toString() : undefined,
},
];
};
Expand Down
5 changes: 3 additions & 2 deletions packages/coin98-wallet/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
"noFallthroughCasesInSwitch": true,
"resolveJsonModule": true
}
}
}
14 changes: 9 additions & 5 deletions packages/core/docs/guides/multilanguage-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@
## Supported languages

- English
- Spanish
- Chinese
- Bulgarian
- Vietnamese
- Korean
- Arabic
- Bulgarian
- Chinese
- Croatian
- Hindi
- Korean
- Macedonian
- Serbian
- Slovenian
- Spanish
- Vietnamese

## How to use

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": "7.9.2",
"version": "7.9.3",
"description": "This is the core package for NEAR Wallet Selector.",
"keywords": [
"near",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
import { mock } from "jest-mock-extended";
import type { FinalExecutionOutcome } from "near-api-js/lib/providers";
import type { JsonRpcProvider } from "near-api-js/lib/providers";
import { providers } from "near-api-js";
import * as nearAPI from "near-api-js";
import {
createQueryResponseMock,
createViewAccessKeyResponseMock,
Expand All @@ -24,7 +24,9 @@ const defaults = {
const setup = (url: string) => {
const provider = mock<JsonRpcProvider>();

jest.spyOn(providers, "JsonRpcProvider").mockImplementation(() => provider);
jest
.spyOn(nearAPI.providers, "JsonRpcProvider")
.mockImplementation(() => provider);

return {
provider,
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/lib/services/provider/provider.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { providers } from "near-api-js";
import * as nearAPI from "near-api-js";
import type {
AccessKeyView,
BlockReference,
Expand All @@ -12,10 +12,10 @@ import type {
} from "./provider.service.types";

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

constructor(url: string) {
this.provider = new providers.JsonRpcProvider({ url });
this.provider = new nearAPI.providers.JsonRpcProvider({ url });
}

query<Response extends QueryResponseKind>(params: QueryParams) {
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/lib/translate/translate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ export type SupportedLanguage =
| "ko"
| "vi"
| "hi"
| "ar";
| "ar"
| "hr"
| "mk"
| "sl"
| "sr";

let chosenLang: string | undefined;
export const allowOnlyLanguage = (langCode: SupportedLanguage | undefined) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/default-wallets/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@near-wallet-selector/default-wallets",
"version": "7.9.2",
"version": "7.9.3",
"description": "Default wallets package for NEAR Wallet Selector.",
"keywords": [
"near",
Expand Down
2 changes: 1 addition & 1 deletion packages/finer-wallet/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@near-wallet-selector/finer-wallet",
"version": "7.9.2",
"version": "7.9.3",
"description": "FiNER Wallet package for NEAR Wallet Selector.",
"keywords": [
"near",
Expand Down
Loading

0 comments on commit 13edffd

Please sign in to comment.