Skip to content

Commit

Permalink
Add TS support for Interaction object (#1802)
Browse files Browse the repository at this point in the history
  • Loading branch information
nialexsan authored Nov 27, 2023
1 parent 6966ec7 commit 699303c
Show file tree
Hide file tree
Showing 82 changed files with 476 additions and 288 deletions.
9 changes: 9 additions & 0 deletions .changeset/brown-dingos-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@onflow/transport-http": minor
"@onflow/typedefs": minor
"@onflow/types": minor
"@onflow/fcl": minor
"@onflow/sdk": minor
---

TS conversion
87 changes: 37 additions & 50 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@
"@changesets/cli": "^2.21.1",
"@types/jest": "^29.5.3",
"@types/node": "^18.11.18",
"@typescript-eslint/eslint-plugin": "^6.3.0",
"@typescript-eslint/parser": "^6.3.0",
"eslint": "^8.46.0",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"lerna": "^6.6.2",
"prettier": "^2.6.2",
"ts-jest": "^29.1.1"
"ts-jest": "^29.1.1",
"typescript": "^5.1.6"
}
}
17 changes: 17 additions & 0 deletions packages/sdk/TRANSITIONS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Transitions

## 0010 Deprecate interaction

- **Date:** Sept 25th 2023
- **Type:** Deprecation of interaction method

The "interaction" method has been deprecated and will be removed in future versions.

Please update your code to use the "initInteraction" method for improved functionality and compatibility.

```javascript
// Deprecated:
const result = interaction();

// Recommended:
const result = initInteraction();
```

## 0009 Deprecate default compute limit

- **Date:** Jun 7th 2022
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"devDependencies": {
"@onflow/fcl-bundle": "^1.4.1",
"@onflow/typedefs": "^1.2.1",
"@types/uuid": "^9.0.6",
"eslint": "^8.35.0",
"eslint-plugin-jsdoc": "^40.0.1",
"jest": "^29.5.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ const response = await sdk.send(await sdk.build([

- [Builders](./src/build)

- [`sdk.args` & `sdk.arg`](./src/build/build-arguments.js)
- [`sdk.args` & `sdk.arg`](./src/build/build-arguments.ts)
- [`sdk.atBlockHeight`](./src/build/build-at-block-height.js)
- [`sdk.atBlockId`](./src/build/build-at-block-id.js)
- [`sdk.authorizations` & `authorization`](./src/build/build-authorizations.js)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {pipe, makeArgument} from "../interaction/interaction.js"
import {pipe, makeArgument} from "../interaction/interaction"
import {TypeDescriptorInput, TypeDescriptor} from "@onflow/types"

/**
* @description - A utility builder to be used with other builders to pass in arguments with a value and supported type
Expand All @@ -15,6 +16,9 @@ export function args(ax = []) {
* @param {Function} xform - A function to transform the value
* @returns {object} - An argument object
*/
export function arg(value, xform) {
export function arg<T extends TypeDescriptor<any, {
type: string;
value: string;
}>>(value: TypeDescriptorInput<T>, xform: T) {
return {value, xform}
}
2 changes: 1 addition & 1 deletion packages/sdk/src/build/build-at-block-height.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {pipe} from "../interaction/interaction.js"
import {pipe} from "../interaction/interaction"
import {validator} from "./build-validator.js"

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/src/build/build-at-block-height.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {interaction} from "../interaction/interaction.js"
import {initInteraction} from "../interaction/interaction"
import {atBlockHeight} from "./build-at-block-height.js"

describe("Build At Block ID", () => {
test("At Block ID", async () => {
const blockHeight = 123

const ix = await atBlockHeight(blockHeight)(interaction())
const ix = await atBlockHeight(blockHeight)(initInteraction())

expect(ix.block.height).toBe(blockHeight)
})
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/build/build-at-block-id.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {isGetAccount, pipe, Ok} from "../interaction/interaction.js"
import {isGetAccount, pipe, Ok} from "../interaction/interaction"
import {validator} from "./build-validator.js"

export function atBlockId(id) {
Expand Down
Loading

0 comments on commit 699303c

Please sign in to comment.