@@ -2,7 +2,7 @@ import { commons, universal, v1, v2 } from '@0xsequence/core'
2
2
import { migrator } from '@0xsequence/migration'
3
3
import { ethers } from 'ethers'
4
4
import { ConfigTracker , PresignedConfig , PresignedConfigLink , SignerSignature } from '../../tracker'
5
- import { Sessions , SignatureType , Transaction } from './sessions.gen'
5
+ import { Sessions , SignatureType , Transaction , SignerSignature as SessionsSignerSignature } from './sessions.gen'
6
6
7
7
export class RemoteConfigTracker implements ConfigTracker , migrator . PresignedMigrationTracker {
8
8
private readonly sessions : Sessions
@@ -58,36 +58,27 @@ export class RemoteConfigTracker implements ConfigTracker, migrator.PresignedMig
58
58
chainId : ethers . BigNumberish
59
59
signatures : string [ ] | SignerSignature [ ]
60
60
} ) : Promise < void > {
61
- let filteredSignatures = args . signatures
62
- if ( this . onlyRecoverable ) {
63
- filteredSignatures = filteredSignatures . filter ( signature => {
64
- if ( typeof signature === 'string' ) {
65
- return commons . signer . canRecover ( signature )
66
- } else {
67
- return ! ! signature . address
61
+ const signerSignatures : SessionsSignerSignature [ ] = [ ]
62
+ for ( const signature of args . signatures ) {
63
+ if ( typeof signature === 'string' ) {
64
+ if ( ! this . onlyRecoverable || commons . signer . canRecover ( signature ) ) {
65
+ signerSignatures . push ( { signature } )
68
66
}
69
- } ) as string [ ] | SignerSignature [ ]
67
+ } else {
68
+ signerSignatures . push ( {
69
+ signer : signature . address ,
70
+ signature : signature . signature ,
71
+ referenceChainID : signature . referenceChainId ?. toString ( )
72
+ } )
73
+ }
70
74
}
71
75
72
- if ( filteredSignatures . some ( sig => typeof sig === 'string' ) && filteredSignatures . some ( sig => typeof sig === 'object' ) ) {
73
- throw new Error ( 'Signatures must be string[] | SignerSignature[]' )
74
- }
75
- if ( filteredSignatures . length === 0 || typeof args . signatures [ 0 ] === 'string' ) {
76
- await this . sessions . saveSignerSignatures ( {
77
- wallet : args . wallet ,
78
- digest : args . digest ,
79
- chainID : numberString ( args . chainId ) ,
80
- signatures : filteredSignatures as string [ ]
81
- } )
82
- } else {
83
- await this . sessions . saveSignerSignatures2 ( {
84
- wallet : args . wallet ,
85
- digest : args . digest ,
86
- chainID : numberString ( args . chainId ) ,
87
- // Rename "address" to "signer"
88
- signatures : ( filteredSignatures as SignerSignature [ ] ) . map ( ( { address, signature, referenceChainId } ) => ( { signer : address , signature, referenceChainId : referenceChainId ?. toString ( ) } ) )
89
- } )
90
- }
76
+ await this . sessions . saveSignerSignatures2 ( {
77
+ wallet : args . wallet ,
78
+ digest : args . digest ,
79
+ chainID : numberString ( args . chainId ) ,
80
+ signatures : signerSignatures
81
+ } )
91
82
}
92
83
93
84
async configOfImageHash ( args : { imageHash : string } ) : Promise < commons . config . Config | undefined > {
0 commit comments