Skip to content

Commit

Permalink
core: v2 restore effective weight
Browse files Browse the repository at this point in the history
  • Loading branch information
marino39 committed Jul 20, 2023
1 parent ea5fbb6 commit 6618f85
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion core/v2/v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,8 @@ func (l *signatureTreeDynamicSignatureLeaf) recover(ctx context.Context, subdige
}, new(big.Int).SetUint64(uint64(l.weight)), nil

case dynamicSignatureTypeEIP1271:
effectiveWeight := l.weight

if provider != nil {
contract := ethcontract.NewContractCaller(l.address, contracts.IERC1271.ABI, provider)

Expand All @@ -1075,6 +1077,11 @@ func (l *signatureTreeDynamicSignatureLeaf) recover(ctx context.Context, subdige
if magicValue != isValidSignatureMagicValue {
return nil, nil, fmt.Errorf("isValidSignature returned %v, expected %v", hexutil.Encode(magicValue[:]), hexutil.Encode(isValidSignatureMagicValue[:]))
}
} else {
// Set the effective weight to 0
// we can still get the signer address (and its corresponding weight)
// but we should not count it towards the total weight
effectiveWeight = 0
}

signerSignatures.Insert(l.address, core.SignerSignature{
Expand All @@ -1086,7 +1093,7 @@ func (l *signatureTreeDynamicSignatureLeaf) recover(ctx context.Context, subdige
return &WalletConfigTreeAddressLeaf{
Weight: l.weight,
Address: l.address,
}, new(big.Int).SetUint64(uint64(l.weight)), nil
}, new(big.Int).SetUint64(uint64(effectiveWeight)), nil

default:
return nil, nil, fmt.Errorf("unknown dynamic signature type %v", l.type_)
Expand Down

0 comments on commit 6618f85

Please sign in to comment.