Skip to content

Commit

Permalink
chore(release): 0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mguleryuz committed Mar 13, 2024
1 parent cb3b0c4 commit a5b9024
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 62 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [0.0.2](https://github.com/InverterNetwork/sdk/compare/v0.0.1...v0.0.2) (2024-03-13)

### [0.0.1](https://github.com/InverterNetwork/sdk/compare/v0.0.1-alpha.1...v0.0.1) (2024-03-08)

### 0.0.1-alpha.0 (2024-03-08)
Expand Down
Binary file modified bun.lockb
Binary file not shown.
12 changes: 7 additions & 5 deletions package-lock.json

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

8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@inverter-network/sdk",
"version": "0.0.1",
"version": "0.0.2",
"description": "INVERTER typescript SDK",
"main": "./dist/cjs/index.js",
"module": "./dist/index.js",
Expand All @@ -10,7 +10,6 @@
"import": "./dist/index.js"
},
"scripts": {
"compile": "bun run tools/compile/index.ts && prettier --write ./src/data.ts",
"watch": "tsc -w -p ./tsconfig.json",
"build": "npm run clean && tsc -p ./tsconfig.json && tsc -p ./tsconfig.cjs.json",
"clean": "rm -rf dist tsconfig.tsbuildinfo tsconfig.build.tsbuildinfo",
Expand All @@ -24,8 +23,7 @@
"prettier:fix": "prettier --write ./src/.",
"release": "standard-version -a",
"release:alpha": "standard-version -a --prerelease alpha --skip.changelog",
"release:beta": "standard-version -a --prerelease beta --skip.changelog",
"postrelease": "git push --follow-tags origin main"
"release:beta": "standard-version -a --prerelease beta --skip.changelog"
},
"lint-staged": {
"src/**/*.{ts,tsx}": [
Expand Down Expand Up @@ -80,7 +78,7 @@
"abitype": "^1"
},
"dependencies": {
"@inverter-network/abis": "^0.0.3",
"@inverter-network/abis": "^0.0.4",
"viem": "^2.7.8"
}
}
12 changes: 4 additions & 8 deletions src/getModule/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import type {
ModuleKeys,
ModuleVersionKey,
ModuleVersion,
} from '@inverter-network/abis'
import { data } from '@inverter-network/abis'
import type { ModuleKeys, ModuleVersionKey } from '@inverter-network/abis'
import { getModuleVersion } from '@inverter-network/abis'
import { getContract } from 'viem'
import type {
Hex,
Expand All @@ -21,7 +17,6 @@ import { Extras } from '../types/base'
export default function getModule<
K extends ModuleKeys,
V extends ModuleVersionKey,
MV extends ModuleVersion<K, V> = ModuleVersion<K, V>,
W extends WalletClient<Transport, Chain, Account> | undefined = undefined,
>({
name,
Expand All @@ -38,7 +33,8 @@ export default function getModule<
walletClient?: W
extras?: Extras
}) {
const mv = data[name][version]
const mv = getModuleVersion(name, version)
type MV = typeof mv
// if (!isValidModule(mv)) throw new Error('Invalid module')

// If the walletClient is valid add walletAddress to the extras
Expand Down
84 changes: 40 additions & 44 deletions src/getWorkflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
Account,
Chain,
Transport,
erc20Abi,
} from 'viem'
import getModule from './getModule'
import {
Expand All @@ -17,36 +16,31 @@ import {
} from '@inverter-network/abis'

type WorkflowOrientation = {
[T in Exclude<ModuleType, 'orchestrator'>]: {
[T in Exclude<ModuleType, 'orchestrator' | 'external'>]: {
name: Extract<ModuleVersion, { moduleType: T }>['name']
version: Extract<ModuleVersion, { moduleType: T }>['version']
}
}

export default async function getWorkflow<
// with optional workflowOrientation TODO
// O extends WorkflowOrientation | undefined,
O extends WorkflowOrientation,
W extends WalletClient<Transport, Chain, Account> | undefined = undefined,
>({
publicClient,
walletClient,
orchestratorAddress,
workflowOrientation,
}: {
publicClient: PublicClient<Transport, Chain>
walletClient?: WalletClient<Transport, Chain, Account>
walletClient?: W
orchestratorAddress: Hex
// with optional workflowOrientation TODO
// workflowOrientation?: O
workflowOrientation: O
}) {
if (!publicClient) throw new Error('Public client not initialized')

const client = {
public: publicClient,
wallet: walletClient,
}

// 1. initialize orchestrator
const orchestrator = getModule({
name: 'Orchestrator',
Expand All @@ -64,41 +58,15 @@ export default async function getWorkflow<
public: publicClient,
},
}).read.token(),
erc20Contract = getContract({
client,
erc20Module = getModule({
publicClient,
walletClient,
address: erc20Address,
abi: erc20Abi,
name: 'ERC20',
version: 'v1.0',
}),
erc20Decimals = await erc20Contract.read.decimals(),
erc20Symbol = await erc20Contract.read.symbol()

// with optional workflowOrientation TODO
// const addressAndVersions = (async () => {
// if (!workflowOrientation)
// return await Promise.all(
// (await orchestrator.read.listModules.run()).map(async (address) => {
// const contract = getContract({
// client,
// address,
// abi: FlatModule_ABI,
// })

// const name = await contract.read.title(),
// version = await contract.read.version()

// return { name, version, address }
// })
// )

// return await Promise.all(
// Object.values(workflowOrientation).map(async ({ name, version }) => {
// const address =
// await orchestrator.read.findModuleAddressInOrchestrator.run(name)

// return { name, version, address }
// })
// )
// })()
erc20Decimals = await erc20Module.read.decimals.run(),
erc20Symbol = await erc20Module.read.symbol.run()

// 3. initialize modules with extras
const modules = (
Expand All @@ -124,18 +92,46 @@ export default async function getWorkflow<
return acc
}, {}) as {
[K in keyof WorkflowOrientation]: ReturnType<
typeof getModule<O[K]['name'], O[K]['version']>
typeof getModule<O[K]['name'], O[K]['version'], W>
>
}

// RETURN WORKFLOW CONFIG
const returns = {
...modules,
orchestrator,
erc20Contract,
erc20Module,
erc20Decimals,
erc20Symbol,
}

return returns
}

// with optional workflowOrientation TODO
// const addressAndVersions = (async () => {
// if (!workflowOrientation)
// return await Promise.all(
// (await orchestrator.read.listModules.run()).map(async (address) => {
// const contract = getContract({
// client,
// address,
// abi: FlatModule_ABI,
// })

// const name = await contract.read.title(),
// version = await contract.read.version()

// return { name, version, address }
// })
// )

// return await Promise.all(
// Object.values(workflowOrientation).map(async ({ name, version }) => {
// const address =
// await orchestrator.read.findModuleAddressInOrchestrator.run(name)

// return { name, version, address }
// })
// )
// })()

0 comments on commit a5b9024

Please sign in to comment.