Skip to content

Commit

Permalink
Merge branch 'main' into set-multiple-abi-records-with-multi-call
Browse files Browse the repository at this point in the history
  • Loading branch information
storywithoutend committed Jan 31, 2024
2 parents 59d46aa + d223a5b commit 38aff57
Show file tree
Hide file tree
Showing 20 changed files with 375 additions and 429 deletions.
120 changes: 0 additions & 120 deletions packages/ensjs/deploy/01_legacy_dnsregistrar.cjs

This file was deleted.

3 changes: 2 additions & 1 deletion packages/ensjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@
"prepublish": "pnpm build && cp ../../README.md ../../LICENSE ./",
"prepack": "pnpm tsn ./scripts/prepack.ts",
"ver": "pnpm tsn ./scripts/updateVersion.ts",
"generateDocs": "pnpm tsn ./scripts/generateDocs.ts"
"generateDocs": "pnpm tsn ./scripts/generateDocs.ts",
"rcBranchVersion": "pnpm tsn ./scripts/rcBranchVersion.ts"
},
"dependencies": {
"@adraffy/ens-normalize": "1.9.0",
Expand Down
27 changes: 27 additions & 0 deletions packages/ensjs/scripts/rcBranchVersion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { execSync } from 'child_process'
import fs from 'fs-extra'
import path from 'path'
import * as url from 'url'

// get branch name from local git command
const branchName = execSync('git rev-parse --abbrev-ref HEAD')
.toString('utf-8')
.replace(/\//g, '-')
.trim()

// timestamp
const timestamp = new Date().toISOString().replace(/[-:.]/g, '').slice(0, -1)

const newVersion = `0.0.0-${branchName}.${timestamp}`

// // change version in package.json
execSync(`pnpm version --no-workspaces-update ${newVersion}`, {
stdio: 'inherit',
})

const __dirname = url.fileURLToPath(new URL('.', import.meta.url))

// // Writes the new version to `./src/errors/version.ts`.
const versionFilePath = path.join(__dirname, '../src/errors/version.ts')

fs.writeFileSync(versionFilePath, `export const version = '${newVersion}'\n`)
10 changes: 6 additions & 4 deletions packages/ensjs/src/clients/public.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import {
createClient,
type Chain,
type Client,
type ClientConfig,
type PublicRpcSchema,
type Transport,
} from 'viem'
import { addEnsContracts } from '../contracts/addEnsContracts.js'
import type { ChainWithEns } from '../contracts/consts.js'
import type {
ChainWithBaseContracts,
ChainWithEns,
} from '../contracts/consts.js'
import type { Prettify } from '../types.js'
import { ensPublicActions, type EnsPublicActions } from './decorators/public.js'
import {
Expand All @@ -17,7 +19,7 @@ import {

export type EnsPublicClientConfig<
TTransport extends Transport = Transport,
TChain extends Chain = Chain,
TChain extends ChainWithBaseContracts = ChainWithBaseContracts,
> = Pick<
ClientConfig<TTransport, TChain>,
'batch' | 'key' | 'name' | 'pollingInterval' | 'transport'
Expand Down Expand Up @@ -56,7 +58,7 @@ export type EnsPublicClient<
*/
export const createEnsPublicClient = <
TTransport extends Transport,
TChain extends Chain,
TChain extends ChainWithBaseContracts,
>({
batch,
chain,
Expand Down
10 changes: 6 additions & 4 deletions packages/ensjs/src/clients/subgraph.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import {
createClient,
type Chain,
type Client,
type ClientConfig,
type PublicRpcSchema,
type Transport,
} from 'viem'
import { addEnsContracts } from '../contracts/addEnsContracts.js'
import type { ChainWithEns } from '../contracts/consts.js'
import type {
ChainWithBaseContracts,
ChainWithEns,
} from '../contracts/consts.js'
import type { Prettify } from '../types.js'
import {
ensSubgraphActions,
Expand All @@ -16,7 +18,7 @@ import {

export type EnsSubgraphClientConfig<
TTransport extends Transport = Transport,
TChain extends Chain = Chain,
TChain extends ChainWithBaseContracts = ChainWithBaseContracts,
> = Pick<
ClientConfig<TTransport, TChain>,
'batch' | 'key' | 'name' | 'pollingInterval' | 'transport'
Expand Down Expand Up @@ -49,7 +51,7 @@ export type EnsSubgraphClient<
*/
export const createEnsSubgraphClient = <
TTransport extends Transport,
TChain extends Chain,
TChain extends ChainWithBaseContracts,
>({
batch,
chain,
Expand Down
32 changes: 19 additions & 13 deletions packages/ensjs/src/clients/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
createWalletClient,
type Account,
type Address,
type Chain,
type Client,
type ClientConfig,
type ParseAccount,
Expand All @@ -11,23 +10,30 @@ import {
type WalletRpcSchema,
} from 'viem'
import { addEnsContracts } from '../contracts/addEnsContracts.js'
import type { ChainWithEns } from '../contracts/consts.js'
import type { Prettify } from '../types.js'
import type {
ChainWithBaseContracts,
ChainWithEns,
CheckedChainWithEns,
} from '../contracts/consts.js'
import type { Assign, Prettify } from '../types.js'
import { ensWalletActions, type EnsWalletActions } from './decorators/wallet.js'

export type EnsWalletClientConfig<
TTransport extends Transport,
TChain extends Chain,
TChain extends ChainWithBaseContracts,
TAccountOrAddress extends Account | Address | undefined =
| Account
| Address
| undefined,
> = Pick<
ClientConfig<TTransport, TChain, TAccountOrAddress>,
'account' | 'chain' | 'key' | 'name' | 'pollingInterval' | 'transport'
> & {
chain: TChain
}
> = Assign<
Pick<
ClientConfig<TTransport, TChain, TAccountOrAddress>,
'account' | 'chain' | 'key' | 'name' | 'pollingInterval' | 'transport'
>,
{
chain: TChain
}
>

export type EnsWalletClient<
TTransport extends Transport = Transport,
Expand Down Expand Up @@ -61,7 +67,7 @@ export type EnsWalletClient<
*/
export const createEnsWalletClient = <
TTransport extends Transport,
TChain extends Chain,
TChain extends ChainWithBaseContracts,
TAccountOrAddress extends Account | Address | undefined = undefined,
>({
account,
Expand All @@ -76,12 +82,12 @@ export const createEnsWalletClient = <
TAccountOrAddress
>): EnsWalletClient<
TTransport,
ChainWithEns<TChain>,
CheckedChainWithEns<TChain>,
ParseAccount<TAccountOrAddress>
> => {
return createWalletClient({
account,
chain: addEnsContracts<TChain>(chain),
chain: addEnsContracts(chain),
key,
name,
pollingInterval,
Expand Down
6 changes: 3 additions & 3 deletions packages/ensjs/src/contracts/addEnsContracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
addresses,
subgraphs,
supportedChains,
type ChainWithEns,
type CheckedChainWithEns,
type SupportedChain,
} from './consts.js'

Expand All @@ -22,7 +22,7 @@ import {
* transport: http(),
* })
*/
export const addEnsContracts = <TChain extends Chain>(chain: TChain) => {
export const addEnsContracts = <const TChain extends Chain>(chain: TChain) => {
if (!chain) throw new NoChainError()
if (!supportedChains.includes(chain.network as SupportedChain))
throw new UnsupportedNetworkError({
Expand All @@ -38,5 +38,5 @@ export const addEnsContracts = <TChain extends Chain>(chain: TChain) => {
subgraphs: {
...subgraphs[chain.network as SupportedChain],
},
} as ChainWithEns<TChain>
} as unknown as CheckedChainWithEns<TChain>
}
Loading

0 comments on commit 38aff57

Please sign in to comment.