Skip to content

Commit

Permalink
Merge pull request #7 from grindery-io/egor/user-methods
Browse files Browse the repository at this point in the history
Add Wallet API methods
  • Loading branch information
milukove authored Oct 21, 2024
2 parents f7d3544 + 9cc015e commit 5acee47
Show file tree
Hide file tree
Showing 113 changed files with 1,694 additions and 328 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Grindery Wallet SDK Changelog

## v0.5.0 (2024-09-27)

### Added

- [`WalletAPI` class](https://grindery-io.github.io/grindery-wallet-sdk/classes/classes_WalletAPI.WalletAPI.html), a simple wrapper for Grindery Wallet API
- [`getUser` SDK method](https://github.com/grindery-io/grindery-wallet-sdk#getting-user-information), allowing to get information about connected Grindery user

### Fixed

- Pairing redirect [issue](https://github.com/grindery-io/grindery-wallet-sdk/issues/8) when SDK used in the Telegram Mini App

## v0.4.2 (2024-08-03)

- Added client events tracking
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ The SDK enables your dapp to provide a seamless user experience for Grindery use
- [Sending transactions](#sending-transactions)
- [Signing](#signing)
- [Chain switching](#chain-switching)
- [Getting user information](#getting-user-information)
- [Advanced usage](#advanced-usage)
- [Full documentation](#full-documentation)
- [Injected Ethereum Provider](#injected-ethereum-provider)
Expand Down Expand Up @@ -239,6 +240,16 @@ WalletSDK.on('accountsChanged', () => {
});
```

## Getting user information

To get information about connected Grindery Wallet User use [`getUser()`](https://grindery-io.github.io/grindery-wallet-sdk/classes/classes_WalletSDK.WalletSDK.html#getUser) method, once the wallet is connected:

```typescript
WalletSDK.on('accountsChanged', async () => {
console.log('user', await WalletSDK.getUser());
});
```

# Advanced usage

## Full documentation
Expand Down
14 changes: 14 additions & 0 deletions dist/classes/WalletAPI.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* @summary The Grindery Wallet API wrapper class
* @since 0.5.0
*/
export declare class WalletAPI {
/**
* @summary Sends a request to the Grindery Wallet API
* @public
* @param {string} method JSON-RPC method name
* @param {object} params JSON-RPC method parameters, optional
* @returns {T} The result of the API request
*/
sendApiRequest<T>(method: string, params?: object): Promise<T>;
}
13 changes: 13 additions & 0 deletions dist/classes/WalletSDK.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ProviderEventName } from './EventEmitter';
import { Provider } from './Provider';
import { RpcRequestResults } from './Rpc';
import { User } from '../utils/user';
export type WalletSDKConfig = {
appId?: string;
appUrl?: string;
Expand Down Expand Up @@ -107,11 +108,23 @@ export declare class WalletSDK {
* @returns {EventEmitter} The instance of the class itself
*/
removeListener(event: ProviderEventName, callback: Function): this;
/**
* @summary Gets the Grindery user information
* @public
* @since 0.5.0
* @returns {Promise<User>} The Grindery user information
*/
getUser(): Promise<User>;
/**
* @summary SdkStorage class instance
* @private
*/
private storage;
/**
* @summary The Grindery Wallet user
* @private
*/
private user;
/**
* @summary Gets the Grindery Wallet ethereum provider
* @returns {Provider} The Grindery Wallet ethereum provider
Expand Down
151 changes: 136 additions & 15 deletions dist/grindery-wallet-sdk.cjs.development.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/grindery-wallet-sdk.cjs.development.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/grindery-wallet-sdk.cjs.production.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/grindery-wallet-sdk.cjs.production.min.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit 5acee47

Please sign in to comment.