Skip to content

Commit

Permalink
chore(get-nonce-optional-address): add optional address param to getN…
Browse files Browse the repository at this point in the history
…once (#2046)
  • Loading branch information
Cali93 authored Mar 18, 2024
1 parent 581658c commit 9887e9f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/siwe/core/controller/SIWEController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/siwe/core/utils/TypeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface SIWEVerifyMessageArgs {
}

export interface SIWEClientMethods {
getNonce: () => Promise<string>
getNonce: (address?: string) => Promise<string>
createMessage: (args: SIWECreateMessageArgs) => string
verifyMessage: (args: SIWEVerifyMessageArgs) => Promise<boolean>
getSession: () => Promise<SIWESession | null>
Expand Down
6 changes: 3 additions & 3 deletions packages/siwe/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
Expand Down Expand Up @@ -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.')
}
Expand Down

0 comments on commit 9887e9f

Please sign in to comment.