-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
rabbyweb3team001
committed
Aug 20, 2024
1 parent
c083610
commit d782158
Showing
15 changed files
with
676 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"presets": [ | ||
[ | ||
"@nrwl/js/babel", | ||
{ | ||
"useBuiltIns": "usage" | ||
} | ||
] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"extends": ["../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"rules": {} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# @near-wallet-selector/rabby-wallet | ||
|
||
This is the [Rabby Wallet](https://chromewebstore.google.com/detail/rabby-wallet/acmacodkjbdgmoleebolmdjonilkdbch) package for NEAR Wallet Selector. | ||
|
||
## Install Rabby Wallet | ||
|
||
- [Chrome](https://chromewebstore.google.com/detail/rabby-wallet/acmacodkjbdgmoleebolmdjonilkdbch) | ||
|
||
|
||
## Installation and Usage | ||
|
||
The easiest way to use this package is to install it from the NPM registry, this package requires `near-api-js` v1.0.0 or above: | ||
|
||
```bash | ||
# Using Yarn | ||
yarn add near-api-js | ||
|
||
# Using NPM. | ||
npm install near-api-js | ||
``` | ||
```bash | ||
# Using Yarn | ||
yarn add @near-wallet-selector/rabby-wallet | ||
|
||
# Using NPM. | ||
npm install @near-wallet-selector/rabby-wallet | ||
``` | ||
|
||
Then use it in your dApp: | ||
|
||
```ts | ||
import { setupWalletSelector } from "@near-wallet-selector/core"; | ||
import { setupRabbyWallet } from "@near-wallet-selector/rabby-wallet"; | ||
|
||
// Rabby Wallet for Wallet Selector can be setup without any params or it can take few optional params, see options below. | ||
const rabbyWallet = setupRabbyWallet({ | ||
iconUrl: "https://<Wallet Icon URL Here>" // optional | ||
}); | ||
|
||
const selector = await setupWalletSelector({ | ||
network: "mainnet", // Rabby Wallet only supports NEAR Mainnet at the moment. | ||
modules: [rabbyWallet], | ||
}); | ||
``` | ||
|
||
## Options | ||
|
||
- `iconUrl`: (`string?`): Image URL for the icon shown in the modal. This can also be a relative path or base64 encoded image. Defaults is `./assets/rabby-wallet.png`. | ||
- `deprecated`: (`boolean?`): Deprecated is optional. Default is `false`. | ||
|
||
## Assets | ||
|
||
Assets such as icons can be found in the `/assets` directory of the package. Below is an example using Webpack: | ||
|
||
```ts | ||
import { setupRabbyWallet } from "@near-wallet-selector/rabby-wallet"; | ||
import rabbyIconUrl from "@near-wallet-selector/rabby-wallet/assets/rabby-wallet.png"; | ||
|
||
const rabbyWallet = setupRabbyWallet({ | ||
iconUrl: rabbyIconUrl | ||
}); | ||
``` | ||
|
||
## Tip | ||
|
||
Rabby Wallet only supports NEAR Mainnet at the moment. | ||
|
||
## License | ||
|
||
This repository is distributed under the terms of both the MIT license and the Apache License (Version 2.0). |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* eslint-disable */ | ||
export default { | ||
displayName: "rabby-wallet", | ||
preset: "../../jest.preset.js", | ||
globals: {}, | ||
transform: { | ||
"^.+\\.[tj]s$": [ | ||
"ts-jest", | ||
{ | ||
tsconfig: "<rootDir>/tsconfig.spec.json", | ||
}, | ||
], | ||
}, | ||
moduleFileExtensions: ["ts", "tsx", "js", "jsx"], | ||
coverageDirectory: "../../coverage/packages/rabby-wallet", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "@near-wallet-selector/rabby-wallet", | ||
"version": "8.9.12", | ||
"description": "rabby Wallet package for NEAR Wallet Selector.", | ||
"keywords": [ | ||
"near", | ||
"blockchain", | ||
"wallets", | ||
"dapps", | ||
"near-protocol", | ||
"near-blockchain", | ||
"wallet selector", | ||
"injected wallet", | ||
"Rabby wallet" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/near/wallet-selector.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/near/wallet-selector/issues" | ||
}, | ||
"homepage": "https://github.com/near/wallet-selector/tree/main/packages/rabby-wallet" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ | ||
"name": "rabby-wallet", | ||
"$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "packages/rabby-wallet/src", | ||
"projectType": "library", | ||
"targets": { | ||
"build": { | ||
"executor": "@nrwl/rollup:rollup", | ||
"outputs": ["{options.outputPath}"], | ||
"options": { | ||
"outputPath": "dist/packages/rabby-wallet", | ||
"tsConfig": "packages/rabby-wallet/tsconfig.lib.json", | ||
"project": "packages/rabby-wallet/package.json", | ||
"entryFile": "packages/rabby-wallet/src/index.ts", | ||
"buildableProjectDepsInPackageJsonType": "dependencies", | ||
"compiler": "babel", | ||
"format": ["esm", "cjs"], | ||
"assets": [ | ||
{ | ||
"glob": "packages/rabby-wallet/README.md", | ||
"input": ".", | ||
"output": "." | ||
}, | ||
{ | ||
"glob": "packages/rabby-wallet/assets/*", | ||
"input": ".", | ||
"output": "assets" | ||
} | ||
] | ||
} | ||
}, | ||
"lint": { | ||
"executor": "@nx/linter:eslint", | ||
"outputs": ["{options.outputFile}"], | ||
"options": { | ||
"lintFilePatterns": ["packages/rabby-wallet/**/*.ts"] | ||
} | ||
}, | ||
"test": { | ||
"executor": "@nx/jest:jest", | ||
"outputs": ["{workspaceRoot}/coverage/packages/rabby-wallet"], | ||
"options": { | ||
"jestConfig": "packages/rabby-wallet/jest.config.ts", | ||
"passWithNoTests": true | ||
} | ||
}, | ||
"deploy": { | ||
"executor": "ngx-deploy-npm:deploy", | ||
"options": { | ||
"access": "public" | ||
}, | ||
"dependsOn": ["^deploy"] | ||
} | ||
}, | ||
"tags": ["injected-wallet"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { setupRabbyWallet } from "./lib/rabby-wallet"; | ||
export type { RabbyWalletParams } from "./lib/rabby-wallet"; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
export interface AccessKey { | ||
publicKey: string; | ||
secretKey: string; | ||
} | ||
|
||
interface RequestSignInResponse { | ||
accessKey: AccessKey; | ||
accountId: string; | ||
error: string | { type: string }; | ||
} | ||
|
||
export type SignOutResponse = true | { error: string | { type: string } }; | ||
|
||
interface RequestSignInParams { | ||
contractId?: string; | ||
methodNames?: Array<string>; | ||
} | ||
|
||
interface Action { | ||
methodName: string; | ||
args: object; | ||
gas: string; | ||
deposit: string; | ||
} | ||
|
||
interface SignAndSendTransactionParams { | ||
receiverId: string; | ||
actions: Array<Action>; | ||
} | ||
|
||
export interface SignAndSendTransactionResponse { | ||
method: string; | ||
txHash: string; | ||
code: number; | ||
} | ||
|
||
interface Transaction { | ||
receiverId: string; | ||
actions: Array<Action>; | ||
} | ||
|
||
interface RequestSignTransactionsParams { | ||
transactions: Array<Transaction>; | ||
} | ||
|
||
interface RequestSignTransactionsResponse { | ||
txs: Array<{ | ||
signedTx: string; | ||
}>; | ||
} | ||
|
||
export interface RabbyEvents { | ||
signIn: () => void; | ||
signOut: () => void; | ||
accountChanged: (changedAccountId: string) => void; | ||
} | ||
|
||
export interface InjectedRabby { | ||
getAccountId: () => string | null; | ||
requestSignIn: ( | ||
params: RequestSignInParams | ||
) => Promise<RequestSignInResponse>; | ||
signOut: () => Promise<SignOutResponse>; | ||
isSignedIn: () => boolean; | ||
on: <Event extends keyof RabbyEvents>( | ||
event: Event, | ||
callback: RabbyEvents[Event] | ||
) => void; | ||
signTransaction: (params: SignAndSendTransactionParams) => Promise<string>; | ||
requestSignTransactions: ( | ||
params: RequestSignTransactionsParams | ||
) => Promise<RequestSignTransactionsResponse>; | ||
} |
Oops, something went wrong.