Skip to content

Commit

Permalink
fix swap contract
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffrieh committed Apr 30, 2024
1 parent 4097946 commit d318665
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 76 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/changesets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,23 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

release:
name: Release
needs: verify
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: write
id-token: write
# release:
# name: Release
# needs: verify
# runs-on: ubuntu-latest
# timeout-minutes: 5
# permissions:
# contents: write
# id-token: write

steps:
- name: Clone repository
uses: actions/checkout@v4
# steps:
# - name: Clone repository
# uses: actions/checkout@v4

- uses: oven-sh/setup-bun@v1
# - uses: oven-sh/setup-bun@v1

- name: Install dependencies
run: bun install --frozen-lockfile
# - name: Install dependencies
# run: bun install --frozen-lockfile

# - name: Publish to NPM
# uses: changesets/action@v1
Expand Down
122 changes: 61 additions & 61 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,63 +1,63 @@
{
"name": "@effectai/effect-js",
"version": "2.0.0",
"description": "Effect Network Javscript/Typescript SDK (for [https://effect.network](https://effect.network))",
"main": "./dist/exports/index.js",
"module": "./dist/exports/index.js",
"browser": "dist/exports/index.js",
"types": "./dist/exports/index.d.ts",
"files": ["dist"],
"scripts": {
"test": "vitest run",
"dev": "tsc -w",
"build": "tsc --module es2020",
"lint": "bun biome lint --apply .",
"format": "biome format --write .",
"check": "bun biome check --apply .",
"changeset": "changeset",
"changeset:public": "bun scripts/updateVersion.ts && bun build && changeset publish",
"changeset:version": "changeset version && bun install --frozen-lockfile && bun scripts/updateVersion.ts",
"docs:dev": "cd docs && bun run dev",
"docs:build": "cd docs && bun run build",
"docs:preview": "cd docs && bun run preview"
},
"repository": {
"type": "git",
"url": "git+https://github.com/effectai/effect-js.git"
},
"keywords": ["efx", "AI", "blockchain", "microtasks"],
"author": {
"name": "Effect-AI",
"url": "https://effect.network",
"email": "[email protected]"
},
"publishConfig": {
"access": "public"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/effectai/effect-js/issues"
},
"homepage": "https://github.com/effectai/effect-js#readme",
"devDependencies": {
"@biomejs/biome": "1.7.0",
"@changesets/changelog-github": "^0.4.5",
"@changesets/cli": "^2.23.2",
"@greymass/abi2core": "^2.0.1",
"@size-limit/preset-big-lib": "^11.1.2",
"@types/dotenv": "^8.2.0",
"dotenv": "^16.3.1",
"typescript": "^5.4.3",
"vitest": "^1.4.0"
},
"dependencies": {
"@wharfkit/antelope": "^1.0.7",
"@wharfkit/session": "^1.2.8",
"@wharfkit/wallet-plugin-privatekey": "^1.0.0",
"ajv": "^8.12.0",
"atomicassets": "^1.5.1",
"idb-keyval": "^6.2.1",
"node-localstorage": "^3.0.5"
},
"trustedDependencies": ["@biomejs/biome"]
"name": "@effectai/effect-js",
"version": "2.0.0",
"description": "Effect Network Javscript/Typescript SDK (for [https://effect.network](https://effect.network))",
"main": "./dist/exports/index.js",
"module": "./dist/exports/index.js",
"browser": "dist/exports/index.js",
"types": "./dist/exports/index.d.ts",
"files": ["dist"],
"scripts": {
"test": "vitest run",
"dev": "tsc -w",
"build": "tsc --module es2020",
"lint": "bun biome lint --apply .",
"format": "biome format --write .",
"check": "bun biome check --apply .",
"changeset": "changeset",
"changeset:public": "bun scripts/updateVersion.ts && bun build && changeset publish",
"changeset:version": "changeset version && bun install --frozen-lockfile && bun scripts/updateVersion.ts",
"docs:dev": "cd docs && bun run dev",
"docs:build": "cd docs && bun run build",
"docs:preview": "cd docs && bun run preview"
},
"repository": {
"type": "git",
"url": "git+https://github.com/effectai/effect-js.git"
},
"keywords": ["efx", "AI", "blockchain", "microtasks"],
"author": {
"name": "Effect-AI",
"url": "https://effect.network",
"email": "[email protected]"
},
"publishConfig": {
"access": "public"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/effectai/effect-js/issues"
},
"homepage": "https://github.com/effectai/effect-js#readme",
"devDependencies": {
"@biomejs/biome": "1.7.0",
"@changesets/changelog-github": "^0.4.5",
"@changesets/cli": "^2.23.2",
"@greymass/abi2core": "^2.0.1",
"@size-limit/preset-big-lib": "^11.1.2",
"@types/dotenv": "^8.2.0",
"dotenv": "^16.3.1",
"typescript": "^5.4.3",
"vitest": "^1.4.0"
},
"dependencies": {
"@wharfkit/antelope": "^1.0.7",
"@wharfkit/session": "^1.2.8",
"@wharfkit/wallet-plugin-privatekey": "^1.0.0",
"ajv": "^8.12.0",
"atomicassets": "^1.5.1",
"idb-keyval": "^6.2.1",
"node-localstorage": "^3.0.5"
},
"trustedDependencies": ["@biomejs/biome"]
}
6 changes: 5 additions & 1 deletion src/actions/token/swap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { type AnyAction, Asset, type Name } from "@wharfkit/antelope";
import type { Client } from "../../client";
import { DefiBoxPairEnum } from "./getDefiBoxPair";
import { getPrice } from "./getPrice";
import { useEFXContracts } from "../../utils/state";

export const swapDirection = {
EfxToUsdt: `${DefiBoxPairEnum.EosEfx}-${DefiBoxPairEnum.EosUsdt}`,
Expand All @@ -13,6 +14,7 @@ export const buildSwapAction = (
actor: Name,
authorization: { permission: Name; actor: Name }[],
amount: number,
tokenContract: string,
efxPrice: number,
) => {
if (!authorization || !authorization.length || !actor) {
Expand All @@ -29,7 +31,7 @@ export const buildSwapAction = (
[key: string]: AnyAction;
} = {
[swapDirection.EfxToUsdt]: {
account: "effecttokens",
account: tokenContract,
name: "transfer",
authorization,
data: {
Expand Down Expand Up @@ -66,13 +68,15 @@ export const swap = async (
}

const { transact, actor, authorization } = client.session;
const { token } = useEFXContracts(client);
const efxPrice = await getPrice();

const action = buildSwapAction(
direction,
actor,
authorization,
amount,
token,
efxPrice,
);

Expand Down
7 changes: 7 additions & 0 deletions src/exports/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ export {
type vTransferActionArgs,
} from "./../actions/vaccount/transfer";

export {
deposit,
depositAction,
type DepositActionArgs,
type DepositArgs,
} from "./../actions/vaccount/deposit";

export { payout, type PayoutArgs } from "../actions/vaccount/payout";

export { type Client, type ClientOpts, createClient } from "./../client";
Expand Down

0 comments on commit d318665

Please sign in to comment.