-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PKG -- [sdk] Allow for integer string acct.keyId in authorization fun…
…ction
- Loading branch information
Showing
3 changed files
with
69 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@onflow/sdk": patch | ||
--- | ||
|
||
Allow for integer string account.keyId in authorization function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,43 @@ | ||
test("placeholder", () => { | ||
expect(1).toBe(1) | ||
}) | ||
import "jest" | ||
import {resolveAccounts} from "../sdk" | ||
import {interaction, pipe, prepAccount} from "./interaction" | ||
|
||
describe("prepAccount", () => { | ||
test("prepAccount converts account object keyId to integer", async () => { | ||
const keyId = "1" | ||
const acct = { | ||
addr: "f8d6e0586b0a20c7", | ||
keyId, | ||
signingFunction: () => ({ | ||
addr: "f8d6e0586b0a20c7", | ||
signature: "abc123", | ||
}), | ||
} | ||
|
||
const ix = prepAccount(acct, {role: "proposer"})({accounts: {}}) | ||
expect(ix.accounts[ix.proposer].keyId).toBe(parseInt(keyId)) | ||
}) | ||
|
||
test("prepAccount converts authorization function keyId to integer", async () => { | ||
const keyId = "1" | ||
const authz = acct => { | ||
return { | ||
...acct, | ||
addr: "f8d6e0586b0a20c7", | ||
keyId, | ||
signingFunction: () => ({ | ||
addr: "f8d6e0586b0a20c7", | ||
signature: "abc123", | ||
}), | ||
} | ||
} | ||
|
||
const ix = await resolveAccounts( | ||
prepAccount(authz, {role: "proposer"})({ | ||
accounts: {}, | ||
}) | ||
) | ||
ix.accounts[ix.proposer] = ix.accounts[ix.proposer].resolve() | ||
expect(ix.accounts[ix.proposer].keyId).toBe(parseInt(keyId)) | ||
}) | ||
}) |