Skip to content

Commit 207bbc6

Browse files
committed
relayer: allow for multiple factory-targetting txns in v3 bundles
1 parent 0359e4f commit 207bbc6

1 file changed

Lines changed: 12 additions & 15 deletions

File tree

relayer.go

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -129,20 +129,15 @@ func EncodeTransactionsForRelayingV3(relayer Relayer, walletAddress common.Addre
129129
return common.Address{}, nil, fmt.Errorf("cannot encode empty transactions")
130130
}
131131

132-
var (
133-
deployTxn *Transaction
134-
walletTxns = make(Transactions, 0, len(txns))
135-
)
132+
var deployTxnCount int
136133
for _, txn := range txns {
137134
if txn.To == walletContext.FactoryAddress {
138-
deployTxn = txn
139-
} else {
140-
walletTxns = append(walletTxns, txn)
135+
deployTxnCount++
141136
}
142137
}
143138

144-
if deployTxn == nil {
145-
payload, err := walletTxns.Payload(walletAddress, chainID, space, nonce)
139+
if deployTxnCount == 0 {
140+
payload, err := txns.Payload(walletAddress, chainID, space, nonce)
146141
if err != nil {
147142
return common.Address{}, nil, err
148143
}
@@ -155,10 +150,12 @@ func EncodeTransactionsForRelayingV3(relayer Relayer, walletAddress common.Addre
155150
return walletAddress, execdata, nil
156151
}
157152

158-
guestTxns := Transactions{deployTxn}
153+
for i, txn := range txns {
154+
if txn.To == walletContext.FactoryAddress {
155+
continue
156+
}
159157

160-
if len(walletTxns) > 0 {
161-
payload, err := walletTxns.Payload(walletAddress, chainID, space, nonce)
158+
payload, err := Transactions{txn}.Payload(walletAddress, chainID, space, nonce)
162159
if err != nil {
163160
return common.Address{}, nil, err
164161
}
@@ -168,14 +165,14 @@ func EncodeTransactionsForRelayingV3(relayer Relayer, walletAddress common.Addre
168165
return common.Address{}, nil, err
169166
}
170167

171-
guestTxns = append(guestTxns, &Transaction{
168+
txns[i] = &Transaction{
172169
To: walletAddress,
173170
Data: execdata,
174171
RevertOnError: true,
175-
})
172+
}
176173
}
177174

178-
guestPayload, err := guestTxns.Payload(
175+
guestPayload, err := txns.Payload(
179176
walletContext.GuestModuleAddress,
180177
chainID,
181178
big.NewInt(0),

0 commit comments

Comments
 (0)