Skip to content

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

@bthaile

Description

@bthaile

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})
    )
  ])
])

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions