Skip to content
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

feat(svm): add svm clients #828

Closed
wants to merge 12 commits into from
Closed
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/svm/clients/*
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20
- run: yarn install
- run: yarn build

2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -10,6 +10,6 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20
- run: yarn install
- run: yarn lint-check
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ jobs:
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v3
with:
node-version: "18.x"
node-version: "20.x"
always-auth: true
registry-url: "https://registry.npmjs.org"

2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20
- run: yarn install
- run: yarn test
env:
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -32,3 +32,6 @@ yarn-error.log
yarn-debug.log*
gasReporterOutput.json
logs

# generated svm clients
src/svm/clients/
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18
20
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -12,12 +12,14 @@
"node": ">=16.18.0"
},
"scripts": {
"postinstall": "yarn generate-svm-clients",
"start": "yarn typechain && nodemon -e ts,tsx,json,js,jsx --watch ./src --ignore ./dist --exec 'yarn dev'",
"build": "yarn run clean && yarn typechain && yarn run build:cjs & yarn run build:esm & yarn run build:types; wait",
"dev": "yarn run build:cjs & yarn run build:esm & yarn run build:types; wait",
"build:cjs": "tsc --project tsconfig.build.json --module commonjs --outDir ./dist/cjs --removeComments --verbatimModuleSyntax false && echo > ./dist/cjs/package.json '{\"type\":\"commonjs\"}'",
"build:esm": "tsc --project tsconfig.build.json --module es2015 --outDir ./dist/esm && echo > ./dist/esm/package.json '{\"type\":\"module\",\"sideEffects\":false}'",
"build:types": "tsc --project tsconfig.build.json --module esnext --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap",
"generate-svm-clients": "yarn ts-node ./scripts/generate-svm-clients.ts",
"test": "hardhat test",
"test:watch": "hardhat watch test",
"test:run:arweave": "npx -y arlocal",
@@ -95,7 +97,12 @@
"typechain": "^8.3.1",
"typescript": "5",
"winston": "^3.10.0",
"winston-transport": "^4.5.0"
"winston-transport": "^4.5.0",
"@codama/nodes-from-anchor": "^1.1.0",
"@codama/renderers-js": "^1.1.1",
"@coral-xyz/borsh": "^0.30.1",
"@solana/web3.js": "2",
"codama": "^1.2.0"
},
"dependencies": {
"@across-protocol/across-token": "^1.0.0",
@@ -159,4 +166,4 @@
"secp256k1@4.0.3": "4.0.4",
"secp256k1@5.0.0": "5.0.1"
}
}
}
27 changes: 27 additions & 0 deletions scripts/generate-clients.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { createFromRoot } from 'codama';
import { rootNodeFromAnchor, AnchorIdl } from '@codama/nodes-from-anchor';
import { renderVisitor as renderJavaScriptVisitor } from "@codama/renderers-js";
import { SvmSpokeIdl, MulticallHandlerIdl } from "@across-protocol/contracts"
import path from 'path';

let codama = createFromRoot(rootNodeFromAnchor(SvmSpokeIdl as AnchorIdl));
const clientsPath = path.join(__dirname, "..", "src", "svm", "clients");

codama.accept(
renderJavaScriptVisitor(path.join(clientsPath, "SvmSpoke"))
);

codama = createFromRoot(rootNodeFromAnchor(MulticallHandlerIdl as AnchorIdl));
codama.accept(
renderJavaScriptVisitor(path.join(clientsPath, "MulticallHandler"))
);

// codama = createFromRoot(rootNodeFromAnchor(MessageTransmitterIdl as AnchorIdl));
Copy link
Contributor

Choose a reason for hiding this comment

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

we will also need MessageTransmitter client to finalize CCTP messages. It would be better if we could get IDL from upstream, but last time I checked they were not, so we ended up fetching old anchor version IDL from on-chain and converting in our contracts repo. Need to check if this has changed since the latest CCTP upgrade.

// codama.accept(
// renderJavaScriptVisitor(path.join(clientsPath, "MessageTransmitter"))
// );

// codama = createFromRoot(rootNodeFromAnchor(TokenMessengerMinterIdl as AnchorIdl));
// codama.accept(
// renderJavaScriptVisitor(path.join(clientsPath, "TokenMessengerMinter"))
// );
27 changes: 27 additions & 0 deletions scripts/generate-svm-clients.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { createFromRoot } from 'codama';
import { rootNodeFromAnchor, AnchorIdl } from '@codama/nodes-from-anchor';
import { renderVisitor as renderJavaScriptVisitor } from "@codama/renderers-js";
import { SvmSpokeIdl, MulticallHandlerIdl } from "@across-protocol/contracts"
import path from 'path';

let codama = createFromRoot(rootNodeFromAnchor(SvmSpokeIdl as AnchorIdl));
const clientsPath = path.join(__dirname, "..", "src", "svm", "clients");

codama.accept(
renderJavaScriptVisitor(path.join(clientsPath, "SvmSpoke"))
);

codama = createFromRoot(rootNodeFromAnchor(MulticallHandlerIdl as AnchorIdl));
codama.accept(
renderJavaScriptVisitor(path.join(clientsPath, "MulticallHandler"))
);

// codama = createFromRoot(rootNodeFromAnchor(MessageTransmitterIdl as AnchorIdl));
// codama.accept(
// renderJavaScriptVisitor(path.join(clientsPath, "MessageTransmitter"))
// );

// codama = createFromRoot(rootNodeFromAnchor(TokenMessengerMinterIdl as AnchorIdl));
// codama.accept(
// renderJavaScriptVisitor(path.join(clientsPath, "TokenMessengerMinter"))
// );
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -14,3 +14,4 @@ export * as clients from "./clients";
export * as typechain from "./typechain";
export * as caching from "./caching";
export * as providers from "./providers";
export * as svm from "./svm";
2 changes: 2 additions & 0 deletions src/svm/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./clients/SvmSpoke";
export * from "./clients/MulticallHandler";
Loading