Skip to content

Commit

Permalink
feat(deposit): add init options (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenhuugiatri authored Dec 2, 2024
1 parent 0082682 commit f29565d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/waypoint/deposit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Parameters for the `Deposit` class:
| --- | --- | --- |
| `clientId` | Required | The client ID from the Developer Console. For more information, see [Waypoint service settings](https://docs.skymavis.com/mavis/ronin-waypoint/guides/get-started#steps).|
| `redirectUri` | Optional | Equivalent to the **REDIRECT URI** configured in [Waypoint service settings](https://docs.skymavis.com/mavis/ronin-waypoint/guides/get-started#step-3-configure-ronin-waypoint-settings). Default is `window.location.origin`. |
| `theme` | Optional | `light` or `dark`. |

## Usage

Expand Down
10 changes: 10 additions & 0 deletions packages/waypoint/deposit/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export type DepositConfig = {
clientId: string
waypointOrigin?: string
redirectUri?: string
environment?: "development" | "production"
theme?: "light" | "dark"
}

type OrderSuccessMessage = {
Expand All @@ -31,18 +33,24 @@ export class Deposit {
private readonly clientId: string
private readonly waypointOrigin: string
private readonly redirectUri: string
private readonly environment?: string
private readonly theme?: string
private readonly communicateHelper: CommunicateHelper

constructor(config: DepositConfig) {
const {
waypointOrigin = RONIN_WAYPOINT_ORIGIN_PROD,
redirectUri = typeof window !== "undefined" ? window.location.origin : "",
clientId,
environment,
theme,
} = config

this.waypointOrigin = waypointOrigin
this.clientId = clientId
this.redirectUri = redirectUri
this.environment = environment
this.theme = theme
this.communicateHelper = new CommunicateHelper(waypointOrigin)
}

Expand All @@ -53,6 +61,8 @@ export class Deposit {
const query = {
state,
email,
environment: this.environment,
theme: this.theme,
origin: this.redirectUri,
redirect_uri: this.redirectUri,
wallet_address: walletAddress,
Expand Down
2 changes: 1 addition & 1 deletion packages/waypoint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"repository": {
"url": "https://github.com/skymavis/waypoint-js"
},
"version": "3.2.1",
"version": "3.2.2",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand Down

0 comments on commit f29565d

Please sign in to comment.