Skip to content

Commit

Permalink
PKG -- [sdk] Fix infinite recursion bug for multiple signing keys/arr…
Browse files Browse the repository at this point in the history
…ay authorization function
  • Loading branch information
jribbink authored and justinbarry committed Jun 23, 2022
1 parent 817339c commit 45951f1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/old-spies-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@onflow/sdk": patch
---

Fix infinite recursion bug when using array authorization function (used for multiple signing keys)
4 changes: 3 additions & 1 deletion packages/sdk/src/resolve/resolve-accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ async function collectAccounts(ix, accounts, last, depth = 3) {

let authorizations = []
for (let ax of accounts) {
let resolve = ax.resolve
ax.resolve = null
var old = last || ax
if (isFn(ax.resolve)) ax = await ax.resolve(ax, buildPreSignable(ax, ix))
if (isFn(resolve)) ax = await resolve(ax, buildPreSignable(ax, ix))

if (Array.isArray(ax)) {
await collectAccounts(ix, ax, old, depth - 1)
Expand Down
4 changes: 0 additions & 4 deletions packages/sdk/src/resolve/resolve-accounts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ test("Voucher in PreSignable multiple payer keys", async () => {
addr: "0x02",
keyId: 0,
}),
resolve: null,
},
{
...account,
Expand All @@ -89,7 +88,6 @@ test("Voucher in PreSignable multiple payer keys", async () => {
addr: "0x02",
keyId: 1,
}),
resolve: null,
},
],
}
Expand Down Expand Up @@ -151,7 +149,6 @@ test("Voucher in PreSignable multiple payer keys different accounts", async () =
addr: "0x02",
keyId: 0,
}),
resolve: null,
},
{
...account,
Expand All @@ -164,7 +161,6 @@ test("Voucher in PreSignable multiple payer keys different accounts", async () =
addr: "0x02",
keyId: 1,
}),
resolve: null,
},
],
}
Expand Down

0 comments on commit 45951f1

Please sign in to comment.