Skip to content

Commit

Permalink
Merge pull request #787 from near/dev
Browse files Browse the repository at this point in the history
v8.0.2 Release (dev -> main)
  • Loading branch information
kujtimprenkuSQA authored Apr 26, 2023
2 parents 5311da0 + f10eb15 commit 8a232e4
Show file tree
Hide file tree
Showing 38 changed files with 455 additions and 48 deletions.
74 changes: 58 additions & 16 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"node": true,
"jest": true
},
"ignorePatterns": ["**/*"],
"ignorePatterns": [
"**/*"
],
"plugins": [
"@nrwl/nx",
"@typescript-eslint",
Expand All @@ -16,7 +18,12 @@
],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"files": [
"*.ts",
"*.tsx",
"*.js",
"*.jsx"
],
"rules": {
"@nrwl/nx/enforce-module-boundaries": [
"error",
Expand All @@ -26,17 +33,24 @@
"depConstraints": [
{
"sourceTag": "*",
"onlyDependOnLibsWithTags": ["*"]
"onlyDependOnLibsWithTags": [
"*"
]
}
]
}
]
}
},
{
"files": ["*.ts", "*.tsx"],
"files": [
"*.ts",
"*.tsx"
],
"parserOptions": {
"project": ["tsconfig.*?.json"]
"project": [
"tsconfig.*?.json"
]
},
"extends": [
"plugin:@nrwl/nx/typescript",
Expand All @@ -45,7 +59,8 @@
"prettier"
],
"rules": {
"prettier/prettier": ["error",
"prettier/prettier": [
"error",
{
"arrowParens": "always",
"bracketSpacing": true,
Expand All @@ -61,7 +76,8 @@
"insertPragma": false,
"requirePragma": false,
"bracketSameLine": false,
"endOfLine": "auto"
"endOfLine": "auto",
"jsdoc": true
}
],
"@typescript-eslint/ban-ts-comment": "off",
Expand All @@ -72,7 +88,11 @@
"error",
{
"selector": "variableLike",
"format": ["camelCase", "PascalCase", "UPPER_CASE"],
"format": [
"camelCase",
"PascalCase",
"UPPER_CASE"
],
"leadingUnderscore": "allow"
}
],
Expand All @@ -84,11 +104,22 @@
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/array-type": ["error", { "default": "generic" }],
"@typescript-eslint/array-type": [
"error",
{
"default": "generic"
}
],
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/consistent-type-exports": "error",
"curly": ["error", "all"],
"eqeqeq": ["error", "smart"],
"curly": [
"error",
"all"
],
"eqeqeq": [
"error",
"smart"
],
"default-case": "off",
"no-caller": "error",
"no-case-declarations": "off",
Expand All @@ -101,7 +132,10 @@
"no-shadow": "off",
"@typescript-eslint/no-shadow": "error",
"no-unused-expressions": "error",
"radix": ["error", "as-needed"],
"radix": [
"error",
"as-needed"
],
"no-restricted-syntax": [
"error",
{
Expand All @@ -114,14 +148,22 @@
"message": "Call parseFloat directly to guarantee radix param is not incorrectly provided"
}
],
"strict": ["error", "global"],
"strict": [
"error",
"global"
],
"valid-jsdoc": "error"
}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nrwl/nx/javascript"],
"files": [
"*.js",
"*.jsx"
],
"extends": [
"plugin:@nrwl/nx/javascript"
],
"rules": {}
}
]
}
}
5 changes: 3 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.0.1",
"version": "8.0.2",
"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 @@ -83,7 +83,7 @@
"@angular/platform-browser": "~14.0.0",
"@angular/platform-browser-dynamic": "~14.0.0",
"@angular/router": "~14.0.0",
"@here-wallet/core": "^1.4.0",
"@here-wallet/core": "^1.4.3",
"@jscutlery/semver": "^2.30.1",
"@ledgerhq/hw-transport": "6.27.1",
"@ledgerhq/hw-transport-webhid": "6.27.1",
Expand Down Expand Up @@ -179,6 +179,7 @@
"jest": "27.5.1",
"jest-mock-extended": "^2.0.6",
"jest-preset-angular": "^12.2.0",
"jsdoc": "^4.0.2",
"nx": "14.4.2",
"prettier": "^2.7.1",
"react-test-renderer": "18.2.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": "8.0.1",
"version": "8.0.2",
"description": "This is the Export Selector UI 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.0.1",
"version": "8.0.2",
"description": "Coin 98 wallet package for NEAR Wallet Selector.",
"keywords": [
"near",
Expand Down
1 change: 1 addition & 0 deletions packages/core/docs/api/selector.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- `nodeUrl` (`string`): URL for RPC requests.
- `helperUrl` (`string`): URL for creating accounts.
- `explorerUrl` (`string`): URL for the NEAR explorer.
- `indexerUrl` (`string`): URL for the NEAR indexer.
- `debug` (`boolean`): Whether internal logging is enabled.
- `optimizeWalletOrder` (`boolean`): Whether wallet order optimization is enabled.
- `randomizeWalletOrder` (`boolean`): Weather wallet order randomization is enabled.
Expand Down
1 change: 1 addition & 0 deletions packages/core/docs/api/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ console.log(modules); // [{ id: "near-wallet", ... }]

- `Array<AccountState>`
- `accountId` (`string`): NEAR account identifier.
- `publicKey` (`string?`): Account public key.
- `active` (`boolean`): Is account set as active.

**Description**
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.0.1",
"version": "8.0.2",
"description": "This is the core package for NEAR Wallet Selector.",
"keywords": [
"near",
Expand Down
33 changes: 33 additions & 0 deletions packages/core/src/lib/options.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,51 @@ import type { SupportedLanguage } from "./translate/translate";
export type NetworkId = "mainnet" | "testnet";

export interface Network {
/**
* Network ID (e.g. `testnet`).
*/
networkId: string;
/**
* URL for RPC requests.
*/
nodeUrl: string;
/**
* URL for creating accounts.
*/
helperUrl: string;
/**
* URL for the NEAR explorer.
*/
explorerUrl: string;
/**
* URL for the NEAR indexer.
*/
indexerUrl: string;
}

export interface Options {
/**
* ISO 639-1 two-letter language code.
*/
languageCode: SupportedLanguage | undefined;
/**
* Resolved network configuration.
*/
network: Network;
/**
* Whether internal logging is enabled.
*/
debug: boolean;
/**
* Whether wallet order optimization is enabled.
*/
optimizeWalletOrder: boolean;
/**
* Weather wallet order randomization is enabled.
*/
randomizeWalletOrder: boolean;
/**
* The URL where DelegateActions are sent by meta transaction enabled wallet modules.
*/
relayerUrl: string | undefined;
}
42 changes: 42 additions & 0 deletions packages/core/src/lib/store.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,62 @@ import type { BehaviorSubject, Observable } from "rxjs";
import type { Wallet, Account } from "./wallet";

export interface ContractState {
/**
* Account ID of the Smart Contract.
*/
contractId: string;
/**
* List of methods that can only be invoked on the Smart Contract. Empty list means no restriction.
*/
methodNames: Array<string>;
}

export type ModuleState<Variation extends Wallet = Wallet> = {
/**
* Unique identifier for the wallet.
*/
id: Variation["id"];
/**
* Type of the wallet.
*/
type: Variation["type"];
/**
* Meta information about the wallet.
*/
metadata: Variation["metadata"];
/**
* Access functionality of the wallet.
*/
wallet(): Promise<Variation>;
};

export type AccountState = Account & {
/**
* Is account set as active.
*/
active: boolean;
};

export interface WalletSelectorState {
/**
* Returns the signed in contract.
*/
contract: ContractState | null;
/**
* Returns the list of available modules.
*/
modules: Array<ModuleState>;
/**
* Returns the list of signed in accounts.
*/
accounts: Array<AccountState>;
/**
* Returns the ID of the selected wallet.
*/
selectedWalletId: string | null;
/**
* Returns ID-s of 5 recently signed in wallets.
*/
recentlySignedInWallets: Array<string>;
}

Expand Down Expand Up @@ -67,7 +103,13 @@ export type WalletSelectorAction =
};

export interface ReadOnlyStore {
/**
* Retrieve the current state. You can find more information on `WalletSelectorState` {@link https://github.com/near/wallet-selector/blob/main/packages/core/docs/api/state.md | here}.
*/
getState(): WalletSelectorState;
/**
* Subscribe to state changes using the (RxJS) Observable pattern. You can find more information on `WalletSelectorState` {@link https://github.com/near/wallet-selector/blob/main/packages/core/docs/api/state.md | here}.
*/
observable: Observable<WalletSelectorState>;
}

Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/lib/wallet-selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ const createSelector = (
};
};

/**
* Initiates a wallet selector instance
* @param {WalletSelectorParams} params Selector parameters (network, modules...)
* @returns {Promise<WalletSelector>} Returns a WalletSelector object
*/
export const setupWalletSelector = async (
params: WalletSelectorParams
): Promise<WalletSelector> => {
Expand Down
Loading

0 comments on commit 8a232e4

Please sign in to comment.