From 9887e9fc6ed87d947bd648725390ec6204ba1251 Mon Sep 17 00:00:00 2001 From: Cali <32299095+Cali93@users.noreply.github.com> Date: Mon, 18 Mar 2024 22:38:26 +0700 Subject: [PATCH] chore(get-nonce-optional-address): add optional address param to getNonce (#2046) --- packages/siwe/core/controller/SIWEController.ts | 4 ++-- packages/siwe/core/utils/TypeUtils.ts | 2 +- packages/siwe/src/client.ts | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/siwe/core/controller/SIWEController.ts b/packages/siwe/core/controller/SIWEController.ts index 6e0488c8a5..1eadaeca50 100644 --- a/packages/siwe/core/controller/SIWEController.ts +++ b/packages/siwe/core/controller/SIWEController.ts @@ -59,9 +59,9 @@ export const SIWEController = { return state._client }, - async getNonce() { + async getNonce(address?: string) { const client = this._getClient() - const nonce = await client.getNonce() + const nonce = await client.getNonce(address) this.setNonce(nonce) return nonce diff --git a/packages/siwe/core/utils/TypeUtils.ts b/packages/siwe/core/utils/TypeUtils.ts index e0a674366c..0381f8971f 100644 --- a/packages/siwe/core/utils/TypeUtils.ts +++ b/packages/siwe/core/utils/TypeUtils.ts @@ -15,7 +15,7 @@ export interface SIWEVerifyMessageArgs { } export interface SIWEClientMethods { - getNonce: () => Promise + getNonce: (address?: string) => Promise createMessage: (args: SIWECreateMessageArgs) => string verifyMessage: (args: SIWEVerifyMessageArgs) => Promise getSession: () => Promise diff --git a/packages/siwe/src/client.ts b/packages/siwe/src/client.ts index 7514078b43..4fb664e662 100644 --- a/packages/siwe/src/client.ts +++ b/packages/siwe/src/client.ts @@ -46,8 +46,8 @@ export class Web3ModalSIWEClient { this.methods = siweConfigMethods } - async getNonce() { - const nonce = await this.methods.getNonce() + async getNonce(address?: string) { + const nonce = await this.methods.getNonce(address) if (!nonce) { throw new Error('siweControllerClient:getNonce - nonce is undefined') } @@ -81,8 +81,8 @@ export class Web3ModalSIWEClient { } async signIn() { - const nonce = await this.methods.getNonce() const { address } = AccountController.state + const nonce = await this.methods.getNonce(address) if (!address) { throw new Error('An address is required to create a SIWE message.') }