Skip to content

Commit 15fde68

Browse files
authored
Fix panic with empty transaction arguments (#632)
1 parent 9786af2 commit 15fde68

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

flow.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func mustRLPEncode(v interface{}) []byte {
162162
// Note(sideninja): This is a temporary workaround until cadence defines canonical format addressing the issue https://github.com/onflow/flow-go-sdk/issues/286
163163
if tx, ok := v.(payloadCanonicalForm); ok {
164164
for _, arg := range tx.Arguments {
165-
if arg[len(arg)-1] == byte(10) {
165+
if len(arg) > 0 && arg[len(arg)-1] == byte(10) {
166166
arg = arg[:len(tx.Arguments)-1]
167167
}
168168
}

transaction.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ func (t *Transaction) payloadCanonicalForm() payloadCanonicalForm {
380380

381381
// note(sideninja): This is a temporary workaround until cadence defines canonical format addressing the issue https://github.com/onflow/flow-go-sdk/issues/286
382382
for i, arg := range t.Arguments {
383-
if arg[len(arg)-1] == byte(10) { // extra new line character
383+
if len(arg) > 0 && arg[len(arg)-1] == byte(10) { // extra new line character
384384
t.Arguments[i] = arg[:len(arg)-1]
385385
}
386386
}

0 commit comments

Comments
 (0)