Skip to content

Commit

Permalink
remove @certusone as a dependency (#2212)
Browse files Browse the repository at this point in the history
---

Co-authored-by: Kevin Peters <[email protected]>
Co-authored-by: Kevin Peters <[email protected]>
  • Loading branch information
3 people authored Jun 27, 2024
1 parent 4c6d46f commit 59ae3c0
Show file tree
Hide file tree
Showing 348 changed files with 16,187 additions and 80,017 deletions.
24 changes: 19 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ jobs:
with:
node-version: 20
cache: "npm"
cache-dependency-path: "wormhole-connect/package-lock.json"
- run: npm ci
working-directory: wormhole-connect
- run: npm run lint:ci
working-directory: wormhole-connect
test:
runs-on: ubuntu-latest

Expand All @@ -30,9 +33,11 @@ jobs:
with:
node-version: 20
cache: "npm"
cache-dependency-path: "wormhole-connect/package-lock.json"
- run: npm ci
- run: npm run build -w sdk
- run: npm test -w wormhole-connect
working-directory: wormhole-connect
- run: npm test
working-directory: wormhole-connect
env:
REACT_APP_SOLANA_RPC: ${{ vars.REACT_APP_SOLANA_RPC }}

Expand All @@ -43,7 +48,8 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2
- name: Run script
run: cd wormhole-connect && npm i prettier && npm run checksdn
run: echo hi #npm i prettier && npm run checksdn
working-directory: wormhole-connect

check-token-list:
runs-on: ubuntu-latest
Expand All @@ -54,9 +60,11 @@ jobs:
with:
node-version: 20
cache: "npm"
cache-dependency-path: "wormhole-connect/package-lock.json"
- run: npm ci
- run: npm run build -w sdk
- run: cd wormhole-connect && npx tsx scripts/checkForeignAssetsConfig.ts
working-directory: wormhole-connect
- run: npx tsx scripts/checkForeignAssetsConfig.ts
working-directory: wormhole-connect
build-hosted:
runs-on: ubuntu-latest

Expand All @@ -66,8 +74,11 @@ jobs:
with:
node-version: 20
cache: "npm"
cache-dependency-path: "wormhole-connect/package-lock.json"
- run: npm ci
working-directory: wormhole-connect
- run: npm run build:hosted
working-directory: wormhole-connect
build-library:
runs-on: ubuntu-latest

Expand All @@ -77,5 +88,8 @@ jobs:
with:
node-version: 20
cache: "npm"
cache-dependency-path: "wormhole-connect/package-lock.json"
- run: npm ci
working-directory: wormhole-connect
- run: npm run build:lib
working-directory: wormhole-connect
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,5 @@ We welcome contributions and bug fixes. Please see [CONTRIBUTING.md](https://git
This SDK is an open source software SDK that leverages the Wormhole protocol, a cross chain messaging protocol. The SDK does not process payments. THIS SDK AND THE WORMHOLE PROTOCOL ARE PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND. By using or accessing this SDK or Wormhole, you agree that no developer or entity involved in creating, deploying, maintaining, operating this SDK or Wormhole, or causing or supporting any of the foregoing, will be liable in any manner for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of, this SDK or Wormhole, or this SDK or Wormhole themselves, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value. By using or accessing this SDK, you represent that you are not subject to sanctions or otherwise designated on any list of prohibited or restricted parties or excluded or denied persons, including but not limited to the lists maintained by the United States' Department of Treasury's Office of Foreign Assets Control, the United Nations Security Council, the European Union or its Member States, or any other government authority.

Wormhole Connect is an NPM package that interacts with the Wormhole protocol. You assume all risks associated with using the SDK, the Wormhole Connect NPM package, the Wormhole protocol, and digital assets and decentralized systems generally, including but not limited to, that: (a) digital assets are highly volatile; (b) using digital assets is inherently risky due to both features of such assets and the potential unauthorized acts of third parties; (c) you may not have ready access to assets; and (d) you may lose some or all of your tokens or other assets. You agree that you will have no recourse against anyone else for any losses due to the use of the SDK or Wormhole. For example, these losses may arise from or relate to: (i) incorrect information; (ii) software or network failures; (iii) corrupted cryptocurrency wallet files; (iv) unauthorized access; (v) errors, mistakes, or inaccuracies; or (vi) third-party activities.


55 changes: 0 additions & 55 deletions package.json

This file was deleted.

143 changes: 143 additions & 0 deletions scripts/countImports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
const ts = require("typescript");
const fs = require("fs");
const path = require("path");

// searching for imports coming from packages/pathcs matching any of these:
const matchers = ["@certusone"];
//const matchers = ["@wormhole-foundation/wormhole-connect-sdk"];

function walkDirectory(dir, fileList = []) {
const files = fs.readdirSync(dir);
files.forEach((file) => {
const filePath = path.join(dir, file);
const stat = fs.statSync(filePath);

if (stat.isDirectory()) {
// If the file is a directory, recurse into it
walkDirectory(filePath, fileList);
} else if (stat.isFile()) {
// If the file is a regular file, add it to the list
fileList.push(filePath);
}
});

return fileList;
}

function collectImports(filePath) {
if (filePath.includes("node_modules")) return [];

const fileContent = fs.readFileSync(filePath, "utf8");

// Create a SourceFile object representing the file
const sourceFile = ts.createSourceFile(
path.basename(filePath),
fileContent,
ts.ScriptTarget.Latest, // Language version
true // SetParentNodes
);

const imports = [];

// Visitor function to collect imports
function visit(node) {
if (ts.isImportDeclaration(node)) {
const moduleSpecifier = node.moduleSpecifier.getText().slice(1, -1); // Remove the quotes
const importClause = node.importClause;

if (importClause) {
const importDetails = {
filePath,
from: moduleSpecifier,
namedImports: [],
defaultImport: null,
namespaceImport: null,
};

if (importClause.name) {
// Default import
importDetails.defaultImport = importClause.name.getText();
}

if (importClause.namedBindings) {
if (ts.isNamespaceImport(importClause.namedBindings)) {
// Namespace import
importDetails.namespaceImport =
importClause.namedBindings.name.getText();
} else if (ts.isNamedImports(importClause.namedBindings)) {
// Named imports
importClause.namedBindings.elements.forEach((element) => {
const importName = element.name.getText();
const propertyName = element.propertyName
? element.propertyName.getText()
: null;
importDetails.namedImports.push({
name: importName,
alias: propertyName,
});
});
}
}

imports.push(importDetails);
}
}
ts.forEachChild(node, visit);
}

// Start AST traversal
visit(sourceFile);

return imports;
}

const files = walkDirectory(process.argv[2]);

var counts = {};
var filePaths = {};

for (let fp of files) {
const imports = collectImports(fp);
const sdkImports = imports.filter((val) => {
for (let m of matchers) {
if (val.from.includes(m)) return true;
}
return false;
});
if (sdkImports.length > 0) {
//console.log(fp);
//console.log(sdkImports);

for (let im of sdkImports) {
for (let ni of im.namedImports) {
const key = `${ni.name} ${im.from}`;
counts[key] = counts[key] ? counts[key] + 1 : 1;
filePaths[key] = filePaths[key] ? [fp].concat(filePaths[key]) : [fp];
}
}
}
}

var sorted = [];

for (let key of Object.keys(counts)) {
sorted.push([key, counts[key]]);
}

sorted.sort((a, b) => a[1] - b[1]);

let sum = 0;
let unique = 0;

for (let entry of sorted) {
console.log(entry[0], entry[1]);
sum += entry[1];
unique += 1;

for (let fp of filePaths[entry[0]]) {
console.log(" " + fp);
}
}

console.log("total", sum);
console.log("unique", unique);
Loading

0 comments on commit 59ae3c0

Please sign in to comment.