@@ -37,21 +37,9 @@ export class GuardSigner implements signers.SapientSigner {
37
37
return bundle
38
38
}
39
39
40
- async requestSignature (
41
- _id : string ,
42
- message : BytesLike ,
43
- metadata : object ,
44
- callbacks : {
45
- onSignature : ( signature : BytesLike ) => void
46
- onRejection : ( error : string ) => void
47
- onStatus : ( situation : string ) => void
48
- }
49
- ) : Promise < boolean > {
50
- const { onSignature, onRejection } = callbacks
51
-
40
+ async sign ( message : BytesLike , metadata : object ) : Promise < BytesLike > {
52
41
if ( ! commons . isWalletSignRequestMetadata ( metadata ) ) {
53
- onRejection ( 'expected sequence signature request metadata' )
54
- return false
42
+ throw new Error ( 'expected sequence signature request metadata' )
55
43
}
56
44
57
45
const guardTotpCode = ( metadata as { guardTotpCode ?: string } ) . guardTotpCode
@@ -61,8 +49,8 @@ export class GuardSigner implements signers.SapientSigner {
61
49
const coder = universal . genericCoderFor ( metadata . config . version )
62
50
const { encoded } = coder . signature . encodeSigners ( metadata . config , metadata . parts ?? new Map ( ) , [ ] , metadata . chainId )
63
51
64
- try {
65
- const { sig : signature } = await this . guard . signWith ( {
52
+ return (
53
+ await this . guard . signWith ( {
66
54
signer : this . address ,
67
55
request : {
68
56
msg : ethers . utils . hexlify ( message ) ,
@@ -71,17 +59,7 @@ export class GuardSigner implements signers.SapientSigner {
71
59
} ,
72
60
token : guardTotpCode ? { id : AuthMethod . TOTP , token : guardTotpCode } : undefined
73
61
} )
74
-
75
- if ( ethers . utils . arrayify ( signature ) . length === 0 ) {
76
- throw new Error ( 'guard response contained no signature data' )
77
- }
78
-
79
- onSignature ( signature )
80
- return true
81
- } catch ( error ) {
82
- onRejection ( `unable to request guard signature: ${ error . message ?? error . msg ?? error } ` )
83
- return false
84
- }
62
+ ) . sig
85
63
}
86
64
87
65
notifyStatusChange ( _id : string , _status : Status , _metadata : object ) : void { }
@@ -248,27 +226,13 @@ async function signOwnershipProof(
248
226
const timestamp = new Date ( )
249
227
const typedData = getOwnershipProofTypedData ( proof . walletAddress , timestamp )
250
228
const digest = encodeTypedDataDigest ( typedData )
251
- const randomId = ethers . utils . hexlify ( ethers . utils . randomBytes ( 32 ) )
252
-
253
- return new Promise ( ( resolve , reject ) =>
254
- signer . requestSignature (
255
- randomId ,
256
- digest ,
257
- { } ,
258
- {
259
- onSignature ( signature ) {
260
- resolve ( {
261
- walletAddress : proof . walletAddress ,
262
- timestamp,
263
- signerAddress,
264
- signature : ethers . utils . hexlify ( signature )
265
- } )
266
- } ,
267
- onRejection : reject ,
268
- onStatus ( _situation ) { }
269
- }
270
- )
271
- )
229
+
230
+ return {
231
+ walletAddress : proof . walletAddress ,
232
+ timestamp,
233
+ signerAddress,
234
+ signature : ethers . utils . hexlify ( await signer . sign ( digest , { } ) )
235
+ }
272
236
}
273
237
}
274
238
0 commit comments