diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 5871622b8..eb42c02a9 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -105,6 +105,14 @@ jobs: with: path: contracts/target key: ${{ runner.os }}-v2-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} + + - name: format contracts + artifacts + run: | + yarn install --frozen-lockfile + cd ../ # back to root + make format-contracts + echo "run 'make format-contracts' if this fails" + git diff --stat --exit-code - name: cargo check env: @@ -117,6 +125,3 @@ jobs: cd /repo/contracts &&\ cargo check &&\ cargo clippy -- -D warnings" - - # - run: cargo check - # - run: cargo clippy -- -D warnings diff --git a/Makefile b/Makefile index f2f2079ae..06e3b0077 100644 --- a/Makefile +++ b/Makefile @@ -127,3 +127,7 @@ upgrade-e2e-solana-image: .PHONY: update-e2e-core-deps upgrade-e2e-core-deps: cd ./integration-tests && ../scripts/update-e2e.sh + +.PHONY: format-contracts +format-contracts: + cd ./contracts && cargo fmt && go fmt ./... && yarn format diff --git a/contracts/README.md b/contracts/README.md index 7ee37520d..8407e12cb 100644 --- a/contracts/README.md +++ b/contracts/README.md @@ -56,5 +56,5 @@ Install `https://github.com/gagliardetto/anchor-go` Current version: [v0.2.3](https://github.com/gagliardetto/anchor-go/tree/v0.2.3) ```bash -./scripts/anchor-go-gen.sh +./scripts/anchor-go-gen.sh ``` diff --git a/contracts/artifacts/localnet/access_controller-keypair.json b/contracts/artifacts/localnet/access_controller-keypair.json index 46551c533..7e3348d66 100644 --- a/contracts/artifacts/localnet/access_controller-keypair.json +++ b/contracts/artifacts/localnet/access_controller-keypair.json @@ -1 +1,6 @@ -[88,83,177,128,199,1,114,89,250,247,46,18,107,162,26,125,19,233,229,58,251,38,17,221,10,202,45,185,250,64,243,39,24,4,109,145,171,35,102,148,236,12,238,74,222,116,201,243,109,158,98,122,7,32,21,13,158,190,72,124,157,104,243,12] \ No newline at end of file +[ + 88, 83, 177, 128, 199, 1, 114, 89, 250, 247, 46, 18, 107, 162, 26, 125, 19, + 233, 229, 58, 251, 38, 17, 221, 10, 202, 45, 185, 250, 64, 243, 39, 24, 4, + 109, 145, 171, 35, 102, 148, 236, 12, 238, 74, 222, 116, 201, 243, 109, 158, + 98, 122, 7, 32, 21, 13, 158, 190, 72, 124, 157, 104, 243, 12 +] diff --git a/contracts/artifacts/localnet/ocr_2-keypair.json b/contracts/artifacts/localnet/ocr_2-keypair.json index fac327378..e390abc7b 100644 --- a/contracts/artifacts/localnet/ocr_2-keypair.json +++ b/contracts/artifacts/localnet/ocr_2-keypair.json @@ -1 +1,6 @@ -[9,218,36,113,218,176,180,196,27,75,171,187,105,81,84,58,52,79,85,169,125,13,0,102,214,246,82,252,133,222,160,252,193,218,154,28,253,34,136,185,53,68,165,141,248,188,247,143,17,100,91,130,75,49,212,131,37,18,151,175,201,153,131,185] \ No newline at end of file +[ + 9, 218, 36, 113, 218, 176, 180, 196, 27, 75, 171, 187, 105, 81, 84, 58, 52, + 79, 85, 169, 125, 13, 0, 102, 214, 246, 82, 252, 133, 222, 160, 252, 193, 218, + 154, 28, 253, 34, 136, 185, 53, 68, 165, 141, 248, 188, 247, 143, 17, 100, 91, + 130, 75, 49, 212, 131, 37, 18, 151, 175, 201, 153, 131, 185 +] diff --git a/contracts/artifacts/localnet/store-keypair.json b/contracts/artifacts/localnet/store-keypair.json index 72782ced4..68477bd7d 100644 --- a/contracts/artifacts/localnet/store-keypair.json +++ b/contracts/artifacts/localnet/store-keypair.json @@ -1 +1,6 @@ -[189,212,127,119,126,129,229,12,201,157,100,223,53,182,209,144,82,137,39,42,199,212,116,181,52,188,127,6,123,161,148,74,129,253,6,129,56,138,171,117,217,146,177,54,182,120,125,247,100,54,203,214,204,177,0,83,158,177,77,195,0,245,49,223] \ No newline at end of file +[ + 189, 212, 127, 119, 126, 129, 229, 12, 201, 157, 100, 223, 53, 182, 209, 144, + 82, 137, 39, 42, 199, 212, 116, 181, 52, 188, 127, 6, 123, 161, 148, 74, 129, + 253, 6, 129, 56, 138, 171, 117, 217, 146, 177, 54, 182, 120, 125, 247, 100, + 54, 203, 214, 204, 177, 0, 83, 158, 177, 77, 195, 0, 245, 49, 223 +] diff --git a/contracts/examples/hello-world/tests/hello-world.ts b/contracts/examples/hello-world/tests/hello-world.ts index 3321299d3..845f0d7a3 100644 --- a/contracts/examples/hello-world/tests/hello-world.ts +++ b/contracts/examples/hello-world/tests/hello-world.ts @@ -21,7 +21,9 @@ describe("hello-world", () => { const store = anchor.web3.Keypair.generate(); const feed = anchor.web3.Keypair.generate(); - let storeIdl = JSON.parse(fs.readFileSync("../../target/idl/store.json", "utf-8")); + let storeIdl = JSON.parse( + fs.readFileSync("../../target/idl/store.json", "utf-8") + ); const storeProgram = new Program(storeIdl, CHAINLINK_PROGRAM_ID, provider); // Create a feed @@ -42,14 +44,18 @@ describe("hello-world", () => { feed, header + (liveLength + historicalLength) * transmissionSize ), - ]).rpc({ commitment: "confirmed" }); + ]) + .rpc({ commitment: "confirmed" }); console.log("deployed store"); - await storeProgram.methods.setWriter(owner.publicKey).accounts({ - feed: feed.publicKey, - owner: owner.publicKey, - authority: owner.publicKey, - }).rpc({ commitment: "confirmed" }); + await storeProgram.methods + .setWriter(owner.publicKey) + .accounts({ + feed: feed.publicKey, + owner: owner.publicKey, + authority: owner.publicKey, + }) + .rpc({ commitment: "confirmed" }); console.log("set writer on store"); const scale = new BN(10).pow(new BN(decimals)); @@ -57,20 +63,28 @@ describe("hello-world", () => { let answer = new BN(1).mul(scale); let round = { timestamp: new BN(1), answer }; - let tx = await storeProgram.methods.submit(round).accounts({ + let tx = await storeProgram.methods + .submit(round) + .accounts({ store: store.publicKey, feed: feed.publicKey, authority: owner.publicKey, - }).rpc({ commitment: "confirmed" }); + }) + .rpc({ commitment: "confirmed" }); console.log("value written to store"); // Add your test here. - tx = await program.methods.execute().accounts({ + tx = await program.methods + .execute() + .accounts({ chainlinkFeed: feed.publicKey, chainlinkProgram: CHAINLINK_PROGRAM_ID, - }).rpc({ commitment: "confirmed" }); + }) + .rpc({ commitment: "confirmed" }); console.log("Your transaction signature", tx); - let t = await provider.connection.getTransaction(tx, { commitment: "confirmed" }); + let t = await provider.connection.getTransaction(tx, { + commitment: "confirmed", + }); console.log(t.meta.logMessages); }); }); diff --git a/contracts/package.json b/contracts/package.json index 00e163cef..51174a3c2 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -1,26 +1,26 @@ { - "dependencies": { - "@chainlink/solana-sdk": "../ts", - "@coral-xyz/anchor": "^0.29.0", - "@solana/spl-token": "^0.3.5", - "@solana/web3.js": "^1.50.1 <=1.92.3", - "@types/chai": "^4.2.22", - "@types/mocha": "^9.0.0", - "@types/node": "^14.14.37", - "@types/secp256k1": "^4.0.3", - "bn.js": "^5.2.0", - "borsh": "^0.7.0", - "chai": "^4.3.4", - "ethereum-cryptography": "^0.1.3", - "mocha": "^9.0.0", - "prettier": "^2.5.1", - "rpc-websockets": "<=7.10.0", - "secp256k1": "^4.0.2", - "ts-mocha": "^8.0.0", - "typescript": "^4.5.4" - }, - "scripts": { - "format": "yarn prettier --write .", - "test": "yarn upgrade @chainlink/solana-sdk && ts-mocha -t 1000000 tests/*.ts" - } + "dependencies": { + "@chainlink/solana-sdk": "../ts", + "@coral-xyz/anchor": "^0.29.0", + "@solana/spl-token": "^0.3.5", + "@solana/web3.js": "^1.50.1 <=1.92.3", + "@types/chai": "^4.2.22", + "@types/mocha": "^9.0.0", + "@types/node": "^14.14.37", + "@types/secp256k1": "^4.0.3", + "bn.js": "^5.2.0", + "borsh": "^0.7.0", + "chai": "^4.3.4", + "ethereum-cryptography": "^0.1.3", + "mocha": "^9.0.0", + "prettier": "^2.5.1", + "rpc-websockets": "<=7.10.0", + "secp256k1": "^4.0.2", + "ts-mocha": "^8.0.0", + "typescript": "^4.5.4" + }, + "scripts": { + "format": "yarn prettier --write .", + "test": "yarn upgrade @chainlink/solana-sdk && ts-mocha -t 1000000 tests/*.ts" + } }