Skip to content

Migration to v7 #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 41 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
2681cc8
chore: remove `report.mjs` script
Ansonhkg Oct 23, 2024
736d8d8
feat: use yarn 4.x workspaces
Ansonhkg Oct 23, 2024
5a20ce5
feat: update package name
Ansonhkg Oct 23, 2024
cf828c1
feat: add `yarn` berry
Ansonhkg Oct 23, 2024
bd0aaa0
fix: add empty `yarn.lock`
Ansonhkg Oct 23, 2024
ccdbf7d
fix: should remove inner packages node_modules first
Ansonhkg Oct 23, 2024
6b81146
resolved conflicts
anshss Oct 26, 2024
b66f820
fix: typescript bug for test file
anshss Aug 29, 2024
63f4dd5
merge: resolved conflicts
anshss Oct 26, 2024
543b694
feat: added more examples to test-lit command
anshss Aug 29, 2024
9dc94f7
feat: github action for test-lit
anshss Aug 29, 2024
9574d64
feat: added and excluded pkp-migration project to nx
anshss Aug 29, 2024
386d8a2
feat: bash script to migrate to latest version
anshss Aug 29, 2024
ad2d615
fix: path on project.json and looping in script
anshss Aug 29, 2024
7da4733
feat: action to migrate dependencies to latest version
anshss Aug 29, 2024
482fabc
feat: condition for dependabot on update-lit action
anshss Aug 29, 2024
287ed8f
fix: merge conflict
anshss Sep 8, 2024
cb9c6f7
merge
anshss Sep 24, 2024
5d8a29d
refactor: removed extra file
anshss Aug 29, 2024
bdc62fb
Update test-lit.yml
anshss Sep 1, 2024
8a03074
merge
anshss Sep 24, 2024
26c6081
fix: update-lit to make script executable at the start
anshss Sep 8, 2024
62a7b8d
fix: making update-lit callable with directory context
anshss Sep 8, 2024
0519648
fix: run-test job made required
anshss Sep 8, 2024
d95be3a
merge: resolved conflicts
anshss Oct 26, 2024
fb83dc2
fix: scripts bug fix
anshss Sep 8, 2024
95f3b25
resolved conflicts
anshss Oct 24, 2024
17e142b
resolved conflicts
anshss Oct 24, 2024
2a329fd
resolved conflict
anshss Oct 24, 2024
2043fb4
resolved conflict
anshss Oct 24, 2024
2d41a69
resolved conflicts
anshss Oct 24, 2024
81815d4
resolved conflicts
anshss Oct 25, 2024
a4a7e9f
feat: extended nx
anshss Oct 25, 2024
2e50362
fix: nx
anshss Oct 25, 2024
1c91ef8
fix: nx passing all node tests
anshss Oct 25, 2024
9cb747d
feat: initialized yarn workspace
anshss Oct 26, 2024
24aed0a
feat: migrated and tested on v6.11.0
anshss Oct 26, 2024
3e92d89
rebased over master
anshss Oct 26, 2024
4c911fc
fix: actions fix, nx config fx, ran tests
anshss Oct 26, 2024
7a5d4f2
feat: migration to v7
anshss Oct 26, 2024
6e4fecd
feat: migrated and tested on v7 alpha
anshss Oct 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
ignore:
- dependency-name: "*"
allow:
- dependency-name: "@lit-protocol/lit-node-client"
50 changes: 50 additions & 0 deletions .github/workflows/migrate-lit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Package Migration
on:
pull_request:
branches:
- master
types: [opened]
workflow_dispatch:

jobs:
migrate-package:
if: ${{ github.actor == 'dependabot[bot]' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'

- name: Install dependencies
run: yarn install

- name: Run package migration
run: yarn upgrade:all

- name: Create
id: commit-changes
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub Actions Bot"

if [ "${{ github.event_name }}" = "pull_request" ]; then
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
else
BRANCH_NAME="package-migration-branch-${{ github.sha }}"
git checkout -b "$BRANCH_NAME"
fi

git add .
git commit -m "Automated package migration" || echo "No changes to commit"

echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT

- name: Push changes
if: success()
run: |
git push --set-upstream origin "${{ steps.commit-changes.outputs.branch_name }}"
echo "Pushed to branch: ${{ steps.commit-changes.outputs.branch_name }}"
74 changes: 74 additions & 0 deletions .github/workflows/test-lit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Test Lit Examples

on:
# schedule:
# - cron: '0 0,12 * * *'
pull_request:
branches:
- master
workflow_dispatch:

jobs:
setup-and-test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'

- name: Install root dependencies
run: yarn install

- name: Create .env file for lit-action-using-fetch
run: |
echo "ETHEREUM_PRIVATE_KEY=${{ secrets.ETHEREUM_PRIVATE_KEY }}" > $GITHUB_WORKSPACE/lit-action-using-fetch/nodejs/.env

- name: Create .env file for paying-for-lit
run: |
echo "ETHEREUM_PRIVATE_KEY=${{ secrets.ETHEREUM_PRIVATE_KEY }}" > $GITHUB_WORKSPACE/paying-for-lit/nodejs/.env

- name: Create .env file for payment-delegation-db-relayer
run: |
echo "ETHEREUM_PRIVATE_KEY=${{ secrets.ETHEREUM_PRIVATE_KEY }}" > $GITHUB_WORKSPACE/payment-delegation-db-relayer/nodejs/.env
echo "LIT_NETWORK=${{ secrets.LIT_NETWORK }}" >> $GITHUB_WORKSPACE/payment-delegation-db-relayer/nodejs/.env
echo "LIT_RELAYER_API_KEY=${{ secrets.LIT_RELAYER_API_KEY }}" >> $GITHUB_WORKSPACE/payment-delegation-db-relayer/nodejs/.env
echo "LIT_PAYER_SECRET_KEY=${{ secrets.LIT_PAYER_SECRET_KEY }}" >> $GITHUB_WORKSPACE/payment-delegation-db-relayer/nodejs/.env

- name: Create .env file for pkp-migration
run: |
echo "ETHEREUM_PRIVATE_KEY=${{ secrets.ETHEREUM_PRIVATE_KEY }}" > $GITHUB_WORKSPACE/pkp-migration/nodejs/.env
echo "LIT_FROM_NETWORK=${{ secrets.LIT_FROM_NETWORK }}" >> $GITHUB_WORKSPACE/pkp-migration/nodejs/.env
echo "LIT_TO_NETWORK=${{ secrets.LIT_TO_NETWORK }}" >> $GITHUB_WORKSPACE/pkp-migration/nodejs/.env
echo "ADD_PKP_ETH_ADDRESS_AS_PERMITTED_ADDRESS=${{ secrets.ADD_PKP_ETH_ADDRESS_AS_PERMITTED_ADDRESS }}" >> $GITHUB_WORKSPACE/pkp-migration/nodejs/.env
echo "SEND_PKP_TO_ITSELF=${{ secrets.SEND_PKP_TO_ITSELF }}" >> $GITHUB_WORKSPACE/pkp-migration/nodejs/.env

- name: Create .env file for session-signatures/getLitActionSessionSigs
run: |
echo "ETHEREUM_PRIVATE_KEY=${{ secrets.ETHEREUM_PRIVATE_KEY }}" > $GITHUB_WORKSPACE/session-signatures/getLitActionSessionSigs/.env

- name: Create .env file for session-signatures/getPkpSessionSigs
run: |
echo "ETHEREUM_PRIVATE_KEY=${{ secrets.ETHEREUM_PRIVATE_KEY }}" > $GITHUB_WORKSPACE/session-signatures/getPkpSessionSigs/.env

- name: Create .env file for session-signatures/getSessionSigs
run: |
echo "ETHEREUM_PRIVATE_KEY=${{ secrets.ETHEREUM_PRIVATE_KEY }}" > $GITHUB_WORKSPACE/session-signatures/getSessionSigs/.env

- name: Create .env file for sign-and-combine-ecdsa
run: |
echo "ETHEREUM_PRIVATE_KEY=${{ secrets.ETHEREUM_PRIVATE_KEY }}" > $GITHUB_WORKSPACE/sign-and-combine-ecdsa/nodejs/.env
echo "CHAIN_TO_SEND_TX_ON=${{ secrets.CHAIN_TO_SEND_TX_ON }}" >> $GITHUB_WORKSPACE/sign-and-combine-ecdsa/nodejs/.env

- name: Create .env file for wrapped-keys
run: |
echo "ETHEREUM_PRIVATE_KEY=${{ secrets.ETHEREUM_PRIVATE_KEY }}" > $GITHUB_WORKSPACE/wrapped-keys/nodejs/.env
echo "SOLANA_PRIVATE_KEY=${{ secrets.SOLANA_PRIVATE_KEY }}" >> $GITHUB_WORKSPACE/wrapped-keys/nodejs/.env

- name: Run Tests
run: yarn test-lit
continue-on-error: false
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
/**/*/node_modules
/**/*/.env
/**/*/.env
/**/**/.yarn
/**/*/.yarnrc.yml

node_modules
.nx
.secrets
.pnp.*

14 changes: 14 additions & 0 deletions .secrets.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
LIT_NETWORK=datil-test
LIT_FROM_NETWORK=cayenne
LIT_TO_NETWORK=datil-dev
ADD_PKP_ETH_ADDRESS_AS_PERMITTED_ADDRESS=false
SEND_PKP_TO_ITSELF=false
LIT_PKP_PUBLIC_KEY=
LIT_CAPACITY_CREDIT_TOKEN_ID=
CHAIN_TO_SEND_TX_ON=yellowstone

# private secrets
SOLANA_PRIVATE_KEY=
ETHEREUM_PRIVATE_KEY=
LIT_RELAYER_API_KEY=
LIT_PAYER_SECRET_KEY=
2 changes: 2 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
nodeLinker: node-modules
yarnPath: "scripts/yarn-berry.cjs"
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ These examples are designed to help you get started building with Lit!

Each example has instructions within its own README file!

# Tools
# Test

Reports the versions of dependencies starting with `@lit-protocol`
Test the examples

```
node ./report.mjs --tag=latest
node ./report.mjs --tag=datil-dev
yarn
yarn test-lit
```
6 changes: 3 additions & 3 deletions btc-trigger/nodejs/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "btc-trigger-example",
"name": "btc-trigger-nodejs",
"version": "0.1.0",
"description": "Example of triggering a Bitcoin transaction with Lit Protocol",
"type": "module",
"scripts": {
"test": "npx @dotenvx/dotenvx run -- mocha test/**/*.spec.ts"
},
"dependencies": {
"@lit-protocol/constants": "^6.6.0",
"@lit-protocol/lit-node-client": "^6.6.0",
"@lit-protocol/constants": "^7.0.0-alpha.9",
"@lit-protocol/lit-node-client": "^7.0.0-alpha.9",
"@mempool/mempool.js": "^2.3.0",
"@simplewebauthn/browser": "^10.0.0",
"@types/elliptic": "^6.4.18",
Expand Down
12 changes: 12 additions & 0 deletions btc-trigger/nodejs/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "btc-trigger-nodejs",
"root": "btc-trigger/nodejs",
"targets": {
"test-lit": {
"executor": "nx:run-commands",
"options": {
"command": "cd btc-trigger/nodejs && yarn && yarn test"
}
}
}
}
13 changes: 6 additions & 7 deletions btc-trigger/nodejs/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { LitNodeClient } from "@lit-protocol/lit-node-client";
import { LitNetwork, LIT_RPC, } from "@lit-protocol/constants";
import { LIT_NETWORK, LIT_RPC, LIT_ABILITY } from "@lit-protocol/constants";
import {
createSiweMessageWithRecaps,
generateAuthSig,
LitAbility,
LitActionResource,
LitPKPResource,
} from "@lit-protocol/auth-helpers";
Expand All @@ -26,7 +25,7 @@ const PKP_PUBLIC_KEY = getEnv("PKP_PUBLIC_KEY");
const ETHEREUM_PRIVATE_KEY = getEnv("ETHEREUM_PRIVATE_KEY");
const BTC_DESTINATION_ADDRESS = getEnv("BTC_DESTINATION_ADDRESS");
const BROADCAST_URL = getEnv("BROADCAST_URL");
const LIT_NETWORK = process.env["LIT_NETWORK"] as LIT_NETWORKS_KEYS || LitNetwork.Datil;
const SELECTED_LIT_NETWORK = process.env["LIT_NETWORK"] as LIT_NETWORKS_KEYS || LIT_NETWORK.Datil;
const LIT_CAPACITY_CREDIT_TOKEN_ID = process.env["LIT_CAPACITY_CREDIT_TOKEN_ID"];

const ethersWallet = new ethers.Wallet(
Expand All @@ -44,14 +43,14 @@ export const executeBtcSigning = async () => {

try {
litNodeClient = new LitNodeClient({
litNetwork: LIT_NETWORK,
litNetwork: SELECTED_LIT_NETWORK,
debug: false,
});
await litNodeClient.connect();

const litContracts = new LitContracts({
signer: ethersWallet,
network: LIT_NETWORK,
network: SELECTED_LIT_NETWORK,
debug: false,
});
await litContracts.connect();
Expand Down Expand Up @@ -87,11 +86,11 @@ export const executeBtcSigning = async () => {
resourceAbilityRequests: [
{
resource: new LitPKPResource("*"),
ability: LitAbility.PKPSigning,
ability: LIT_ABILITY.PKPSigning,
},
{
resource: new LitActionResource("*"),
ability: LitAbility.LitActionExecution,
ability: LIT_ABILITY.LitActionExecution,
},
],
authNeededCallback: async ({
Expand Down
Loading