Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS | TS generator, Support Dictionary Cadence parameter types #19

Open
bthaile opened this issue Oct 21, 2023 · 0 comments
Open

JS | TS generator, Support Dictionary Cadence parameter types #19

bthaile opened this issue Oct 21, 2023 · 0 comments
Assignees

Comments

@bthaile
Copy link
Contributor

bthaile commented Oct 21, 2023

When generating JS | TS binding files, support Dictionary of simple types like String and Int

Look into getting json-cadence both parameters and return types and convert to types.

TODO: Verify this code example:

async function executeTransaction(myDict: { [key: string]: number }) {
    const response = await fcl.send([
        fcl.transaction(cadenceTx),
        fcl.args([
            fcl.arg(myDict, t.Dictionary({ key: t.String, value: t.Int })) // Assuming FCL has a Dictionary type
        ]),
        // Add other transaction configurations...
    ]);

    return await fcl.decode(response);
}

Dictionary

import * as t from "@onflow/types"

sdk.build([
  sdk.args([
    sdk.arg(
      [
        {key: 1, value: "one"},
        {key: 2, value: "two"},
      ],
      t.Dictionary({key: t.Int, value: t.String})
    )
  ])
])

sdk.build([
  sdk.args([
    sdk.arg(
      [
        {key: "a", value: "one"},
        {key: "b", value: "two"},
      ],
      t.Dictionary({key: t.String, value: t.String})
    )
  ])
])
@bthaile bthaile self-assigned this Oct 21, 2023
@bthaile bthaile changed the title [JS generator] Support more Cadence parameter types [JS generator] Support Dictionary Cadence parameter types Jan 11, 2024
@bthaile bthaile changed the title [JS generator] Support Dictionary Cadence parameter types JS | TS generator, Support Dictionary Cadence parameter types Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant