Skip to content

Commit

Permalink
feat(contracts): Further simplify scripts by moving required explicit…
Browse files Browse the repository at this point in the history
… types to `use-inkathon`
  • Loading branch information
wottpal committed Dec 12, 2023
1 parent a83972b commit d7ee9d6
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 34 deletions.
8 changes: 4 additions & 4 deletions contracts/scripts/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { deployContract } from '@scio-labs/use-inkathon'
import { getDeploymentData } from './utils/getDeploymentData'
import { initPolkadotJs } from './utils/initPolkadotJs'
import { writeContractAddresses } from './utils/writeContractAddresses'
import { getDeploymentData } from '@/utils/getDeploymentData'
import { initPolkadotJs } from '@/utils/initPolkadotJs'
import { writeContractAddresses } from '@/utils/writeContractAddresses'
import { deployContract } from '@scio-labs/use-inkathon/helpers'

/**
* Script that deploys the greeter contract and writes its address to a file.
Expand Down
11 changes: 8 additions & 3 deletions contracts/scripts/script.template.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { getDeploymentData } from '@/utils/getDeploymentData'
import { initPolkadotJs } from '@/utils/initPolkadotJs'
import { ContractPromise } from '@polkadot/api-contract'
import { contractQuery, contractTx, decodeOutput, deployContract } from '@scio-labs/use-inkathon'
import { getDeploymentData } from './utils/getDeploymentData'
import { initPolkadotJs } from './utils/initPolkadotJs'
import {
contractQuery,
contractTx,
decodeOutput,
deployContract,
} from '@scio-labs/use-inkathon/helpers'

/**
* Example script that updates & reads a message from a greeter contract.
Expand Down
6 changes: 0 additions & 6 deletions contracts/scripts/types/ContractDeployments.type.ts

This file was deleted.

11 changes: 0 additions & 11 deletions contracts/scripts/types/DeployFn.type.ts

This file was deleted.

9 changes: 3 additions & 6 deletions contracts/scripts/utils/initPolkadotJs.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { ApiPromise, Keyring } from '@polkadot/api'
import { IKeyringPair } from '@polkadot/types/types/interfaces'
import { BN } from '@polkadot/util'
import {
SubstrateChain,
getBalance,
getSubstrateChain,
initPolkadotJs as initApi,
} from '@scio-labs/use-inkathon'
import { getSubstrateChain } from '@scio-labs/use-inkathon/chains'
import { getBalance, initPolkadotJs as initApi } from '@scio-labs/use-inkathon/helpers'
import { SubstrateChain } from '@scio-labs/use-inkathon/types'
import * as dotenv from 'dotenv'

// Dynamically load environment from `.env.{chainId}`
Expand Down
4 changes: 2 additions & 2 deletions contracts/scripts/utils/writeContractAddresses.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { DeployedContract } from '@scio-labs/use-inkathon/types'
import { writeFile } from 'fs/promises'
import path from 'path'
import { ContractDeployments } from '../types/ContractDeployments.type'

/**
* Writes each given contract address & blockNumber to a `{baseDir}/{contract}/{network}.ts` file.
* NOTE: Base directory can be configured via the `DIR` environment variable
*/
export const writeContractAddresses = async (
networkId: string,
contractDeployments: ContractDeployments,
contractDeployments: Record<string, DeployedContract>,
metadata?: { [key: string]: string | number },
) => {
const baseDir = process.env.DIR || './deployments'
Expand Down
7 changes: 5 additions & 2 deletions contracts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@
},
"compilerOptions": {
"module": "esnext",
"moduleResolution": "node",
"moduleResolution": "bundler",
"target": "esnext",
"sourceMap": true,
"outDir": "dist",
"resolveJsonModule": true,
"esModuleInterop": true,
"skipLibCheck": true,
"allowJs": true,
"composite": true,
"baseUrl": ".",
"composite": true
"paths": {
"@/*": ["./scripts/*"]
}
},
"exclude": ["node_modules", "dist", "target", "./*/target"],
"include": ["./deployments/**/*.json", "./deployments/**/*.ts", "./scripts/**/*.ts"]
Expand Down

1 comment on commit d7ee9d6

@vercel
Copy link

@vercel vercel bot commented on d7ee9d6 Dec 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.