-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
404 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Publish TypeScript SDK | ||
|
||
on: | ||
push: | ||
branches: ['main'] | ||
pull_request: | ||
paths: ['typescript-sdk/**'] | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
working-directory: './typescript-sdk' | ||
|
||
env: | ||
NIX_VERSION: nix-2.13.2 | ||
NIXPKGS_CHANNEL: nixos-22.11 | ||
NODE_OPTIONS: '--no-warnings' | ||
ACTIONS_RUNNER_DEBUG: true | ||
|
||
jobs: | ||
test-typescript-sdk: | ||
name: 'Test TypeScript SDK' | ||
runs-on: ['ubuntu-latest'] | ||
defaults: | ||
run: | ||
working-directory: './typescript-sdk' | ||
steps: | ||
- name: 'Checkout' | ||
uses: actions/checkout@v4 | ||
|
||
- name: 'Setup bun' | ||
uses: oven-sh/setup-bun@v1 | ||
with: | ||
bun-version: 'latest' | ||
|
||
- name: 'Install Nix' | ||
uses: cachix/install-nix-action@v25 | ||
with: | ||
nix_path: nixpkgs=channel:${{ env.NIXPKGS_CHANNEL }} | ||
github_access_token: ${{ github.token }} | ||
- run: | | ||
nix-channel --add https://nixos.org/channels/${{ env.NIXPKGS_CHANNEL }} nixpkgs | ||
nix-channel --update | ||
- name: 'Build SDK' | ||
working-directory: './typescript-sdk' | ||
run: | | ||
nix build .#typescript-sdk -o dist |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { getBalance } from '#/query.ts' | ||
import { unionActions } from '#/actions' | ||
import { isValidChainId } from '#/constants' | ||
import { createPublicClient, fallback, formatUnits, http, walletActions } from 'viem' | ||
|
||
/** | ||
* bun ./scripts/balance.ts \ | ||
* --chainId '11155111' | '6' \ | ||
* --address '0x3a7c1964ea700Ee19887c747C72e68F84Cb9C5DD' | ||
* | ||
* e.g. | ||
* bun ./scripts/balance.ts --chainId 11155111 --address 0x3a7c1964ea700Ee19887c747C72e68F84Cb9C5DD | ||
* bun ./scripts/balance.ts --chainId 6 --address union14qemq0vw6y3gc3u3e0aty2e764u4gs5lnxk4rv | ||
*/ | ||
|
||
main().catch(_ => { | ||
console.error(_) | ||
process.exit(1) | ||
}) | ||
|
||
async function main() { | ||
const [chainFlag, chainId, addressFlag, address] = process.argv.slice(2) | ||
|
||
if (!chainFlag || !chainId || !addressFlag || !address) | ||
throw new Error('Usage: bun ./scripts/balance.ts --chain <chain> --address <address>') | ||
|
||
if (!isValidChainId(chainId)) throw new Error(`Invalid chain: ${chainId}`) | ||
const client = createPublicClient({ | ||
transport: fallback([ | ||
http(process.env.SEPOLIA_RPC_URL), | ||
http('https://ethereum-sepolia.publicnode.com'), | ||
]), | ||
}) | ||
.extend(walletActions) | ||
.extend(unionActions) | ||
|
||
// @ts-expect-error | ||
const balance = await getBalance(client, { chainId, address: address }) | ||
|
||
console.log({ | ||
[address]: { | ||
chainId, | ||
balance: { | ||
bigint: balance, | ||
number: chainId === '11155111' ? formatUnits(balance, 18) : formatUnits(balance, 6), | ||
}, | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.