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

Update anchor to 0.20 #91

Merged
merged 3 commits into from
Jan 11, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/contract-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
release-artifacts:
runs-on: ubuntu-latest
container:
image: projectserum/build:v0.19.0
image: projectserum/build:v0.20.0
env:
RUSTUP_HOME: "/root/.rustup"
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
build:
runs-on: ubuntu-latest
container:
image: projectserum/build:v0.18.0
image: projectserum/build:v0.20.0
env:
RUSTUP_HOME: "/root/.rustup"
FORCE_COLOR: 1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
name: Test
runs-on: ubuntu-latest
container:
image: projectserum/build:v0.18.0
image: projectserum/build:v0.20.0
env:
RUSTUP_HOME: "/root/.rustup"
FORCE_COLOR: 1
Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:
name: Lint
runs-on: ubuntu-latest
container:
image: projectserum/build:v0.18.0
image: projectserum/build:v0.20.0
env:
RUSTUP_HOME: "/root/.rustup"
FORCE_COLOR: 1
Expand Down
2 changes: 1 addition & 1 deletion contracts/Anchor.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
anchor_version = "0.19.0"
anchor_version = "0.20.0"

[registry]
url = "https://anchor.projectserum.com"
Expand Down
49 changes: 25 additions & 24 deletions contracts/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion contracts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {
"@project-serum/anchor": "^0.19.0",
"@project-serum/anchor": "^0.20.0",
"@solana/spl-token": "^0.1.8",
"@solana/web3.js": "1.30.2",
"@types/chai": "^4.2.22",
Expand Down
2 changes: 1 addition & 1 deletion contracts/programs/access-controller/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ localnet = []
default = ["localnet"]

[dependencies]
anchor-lang = "0.19.0"
anchor-lang = "0.20.0"
static_assertions = "1.1.0"
arrayvec = { version = "0.1.0", path = "../../crates/arrayvec" }
4 changes: 2 additions & 2 deletions contracts/programs/ocr2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ localnet = ["access-controller/localnet", "store/localnet"]
default = ["localnet"]

[dependencies]
anchor-lang = "0.19.0"
anchor-spl = "0.19.0"
anchor-lang = "0.20.0"
anchor-spl = "0.20.0"
static_assertions = "1.1.0"
access-controller = { version = "0.1.0", path = "../access-controller", default-features = false, features = ["cpi"] }
store = { version = "0.1.0", path = "../store", default-features = false, features = ["cpi"] }
Expand Down
4 changes: 2 additions & 2 deletions contracts/programs/ocr2/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ pub struct LeftoverPayment {

#[zero_copy]
pub struct Oracles {
xs: [Oracle; 19], // sadly we can't use const https://github.com/project-serum/anchor/issues/632
xs: [Oracle; MAX_ORACLES],
len: u64,
}
arrayvec!(Oracles, Oracle, u64);

#[zero_copy]
pub struct LeftoverPayments {
xs: [LeftoverPayment; 19], // sadly we can't use const https://github.com/project-serum/anchor/issues/632
xs: [LeftoverPayment; MAX_ORACLES],
len: u64,
}
arrayvec!(LeftoverPayments, LeftoverPayment, u64);
Expand Down
2 changes: 1 addition & 1 deletion contracts/programs/store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ localnet = ["access-controller/localnet"]
default = ["localnet"]

[dependencies]
anchor-lang = "0.19.0"
anchor-lang = "0.20.0"
access-controller = { version = "0.1.0", path = "../access-controller", default-features = false, features = ["cpi"] }
bytemuck = "1.7.2"
arrayvec = { version = "0.1.0", path = "../../crates/arrayvec" }
4 changes: 3 additions & 1 deletion contracts/programs/store/src/state.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use anchor_lang::prelude::*;
use arrayvec::arrayvec;

const MAX_FLAGS: usize = 128;

#[zero_copy]
pub struct Flags {
xs: [Pubkey; 128], // sadly we can't use const https://github.com/project-serum/anchor/issues/632
xs: [Pubkey; MAX_FLAGS],
len: u64,
}

Expand Down
33 changes: 21 additions & 12 deletions contracts/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
"@ethersproject/logger" "^5.5.0"
hash.js "1.1.7"

"@project-serum/anchor@^0.19.0":
version "0.19.0"
resolved "https://registry.yarnpkg.com/@project-serum/anchor/-/anchor-0.19.0.tgz#79f1fbe7c3134860ccbfe458a0e09daf79644885"
integrity sha512-cs0LBmJOrL9eJ8MRNqitnzbpCT5QEzVdJmiIjfNV5YaGn1K9vISR7DtISj3Bdl3KBdLqii4CTw1mpHdi8iXUCg==
"@project-serum/anchor@^0.20.0":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@project-serum/anchor/-/anchor-0.20.0.tgz#547f5c0ff7e66809fa7118b2e3abd8087b5ec519"
integrity sha512-p1KOiqGBIbNsopMrSVoPwgxR1iPffsdjMNCOysahTPL9whX2CLX9HQCdopHjYaGl7+SdHRuXml6Wahk/wUmC8g==
dependencies:
"@project-serum/borsh" "^0.2.2"
"@solana/web3.js" "^1.17.0"
Expand Down Expand Up @@ -151,9 +151,9 @@
integrity sha512-i1KGxqcvJaLQali+WuypQnXwcplhtNtjs66eNsZpp2P2FL/trJJxx/VWsM0YCL2iMoIJrbXje48lvIQAQ4p2ZA==

"@types/node@^14.14.37":
version "14.18.0"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.18.0.tgz#98df2397f6936bfbff4f089e40e06fa5dd88d32a"
integrity sha512-0GeIl2kmVMXEnx8tg1SlG6Gg8vkqirrW752KqolYo1PHevhhZN3bhJ67qHj+bQaINhX0Ra3TlWwRvMCd9iEfNQ==
version "14.18.5"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.18.5.tgz#0dd636fe7b2c6055cbed0d4ca3b7fb540f130a96"
integrity sha512-LMy+vDDcQR48EZdEx5wRX1q/sEl6NdGuHXPnfeL8ixkwCOSZ2qnIyIZmcCbdX0MeRqHhAcHmX+haCbrS8Run+A==

"@types/pbkdf2@^3.0.0":
version "3.1.0"
Expand Down Expand Up @@ -553,7 +553,7 @@ dotenv@10.0.0:
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-10.0.0.tgz#3d4227b8fb95f81096cdd2b66653fb2c7085ba81"
integrity sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==

elliptic@^6.5.2:
elliptic@^6.5.2, elliptic@^6.5.4:
version "6.5.4"
resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.4.tgz#da37cebd31e79a1367e941b592ed1fbebd58abbb"
integrity sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==
Expand Down Expand Up @@ -1135,7 +1135,7 @@ scrypt-js@^3.0.0:
resolved "https://registry.yarnpkg.com/scrypt-js/-/scrypt-js-3.0.1.tgz#d314a57c2aef69d1ad98a138a21fe9eafa9ee312"
integrity sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA==

secp256k1@^4.0.1, secp256k1@^4.0.2:
secp256k1@^4.0.1:
version "4.0.2"
resolved "https://registry.yarnpkg.com/secp256k1/-/secp256k1-4.0.2.tgz#15dd57d0f0b9fdb54ac1fa1694f40e5e9a54f4a1"
integrity sha512-UDar4sKvWAksIlfX3xIaQReADn+WFnHvbVujpcbr+9Sf/69odMwy2MUsz5CKLQgX9nsIyrjuxL2imVyoNHa3fg==
Expand All @@ -1144,6 +1144,15 @@ secp256k1@^4.0.1, secp256k1@^4.0.2:
node-addon-api "^2.0.0"
node-gyp-build "^4.2.0"

secp256k1@^4.0.2:
version "4.0.3"
resolved "https://registry.yarnpkg.com/secp256k1/-/secp256k1-4.0.3.tgz#c4559ecd1b8d3c1827ed2d1b94190d69ce267303"
integrity sha512-NLZVf+ROMxwtEj3Xa562qgv2BK5e2WNmXPiOdVIPLgs6lyTzMvBq0aWTYMI5XCP9jZMVKOcqZLw/Wc4vDkuxhA==
dependencies:
elliptic "^6.5.4"
node-addon-api "^2.0.0"
node-gyp-build "^4.2.0"

serialize-javascript@6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.0.tgz#efae5d88f45d7924141da8b5c3a7a7e663fefeb8"
Expand Down Expand Up @@ -1313,9 +1322,9 @@ type-detect@^4.0.0, type-detect@^4.0.5:
integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==

typescript@^4.4.4:
version "4.5.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.2.tgz#8ac1fba9f52256fdb06fb89e4122fa6a346c2998"
integrity sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==
version "4.5.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.4.tgz#a17d3a0263bf5c8723b9c52f43c5084edf13c2e8"
integrity sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg==

utf-8-validate@^5.0.2:
version "5.0.7"
Expand Down
2 changes: 1 addition & 1 deletion gauntlet/packages/gauntlet-solana/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"dependencies": {
"@chainlink/gauntlet-core": "0.0.7",
"@project-serum/anchor": "^0.18.0",
"@project-serum/anchor": "^0.20.0",
Copy link
Member

Choose a reason for hiding this comment

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

This probably has some breaking changes. Can you open an story just to update this on gauntlet?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I've opened a GH Issue:

Please just append the Gauntlet changes to this PR...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it's mostly coral-xyz/anchor#1108 where the wallet is now only conditionally included

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The browser detection is flawed too coral-xyz/anchor#1233

Copy link
Collaborator

@aalu1418 aalu1418 Jan 10, 2022

Choose a reason for hiding this comment

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

Seems like this is what is happening, but i'm not sure how to solve it as the proposed solution doesn't quite work 🤔
https://stackoverflow.com/a/63639280

Update:
Seems like it's importing it as a existing object not a class...so there's no access to set the key

Fix: import using node syntax rather than TS import syntax

"@project-serum/borsh": "^0.2.2",
"@solana/web3.js": "^1.30.2"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { TransactionResponse } from '../types'
import { Idl, Program, Provider, Wallet } from '@project-serum/anchor'

export default abstract class SolanaCommand extends WriteCommand<TransactionResponse> {
wallet: Wallet
wallet: typeof Wallet
Copy link
Collaborator

@aalu1418 aalu1418 Jan 10, 2022

Choose a reason for hiding this comment

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

Fix:

packages/gauntlet-solana/src/commands/internal/solana.ts:8:11 - error TS2749: 'Wallet' refers to a value, but is being used as a type here. Did you mean 'typeof Wallet'?

8   wallet: Wallet
            ~~~~~~

provider: Provider
abstract execute: () => Promise<Result<TransactionResponse>>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Middleware, Next } from '@chainlink/gauntlet-core'
import { assertions } from '@chainlink/gauntlet-core/dist/utils'
import { Provider, Wallet } from '@project-serum/anchor'
import { Provider } from '@project-serum/anchor'
import { Connection, Keypair } from '@solana/web3.js'
import SolanaCommand from './internal/solana'
const { Wallet } = require('@project-serum/anchor') // module exported dynamically from anchor
Comment on lines +3 to +6
Copy link
Collaborator

@aalu1418 aalu1418 Jan 10, 2022

Choose a reason for hiding this comment

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

Fix:

packages/gauntlet-solana/src/commands/middlewares.ts:28:18 - error TS2351: This expression is not constructable.
  Type 'NodeWallet' has no construct signatures.

28   c.wallet = new Wallet(Keypair.fromSecretKey(Uint8Array.from(JSON.parse(rawPK))))
                    ~~~~~~


const isValidURL = (url: string) => {
var pattern = new RegExp('^(https?)://')
Expand Down
12 changes: 6 additions & 6 deletions gauntlet/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -777,17 +777,17 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"

"@project-serum/anchor@^0.18.0":
version "0.18.2"
resolved "https://registry.yarnpkg.com/@project-serum/anchor/-/anchor-0.18.2.tgz#0f13b5c2046446b7c24cf28763eec90febb28485"
integrity sha512-uyjiN/3Ipp+4hrZRm/hG18HzGLZyvP790LXrCsGO3IWxSl28YRhiGEpKnZycfMW94R7nxdUoE3wY67V+ZHSQBQ==
"@project-serum/anchor@^0.20.0":
version "0.20.1"
resolved "https://registry.yarnpkg.com/@project-serum/anchor/-/anchor-0.20.1.tgz#0937807e807e8332aa708cfef4bcb6cbb88b4129"
integrity sha512-2TuBmGUn9qeYz6sJINJlElrBuPsaUAtYyUsJ3XplEBf1pczrANAgs5ceJUFzdiqGEWLn+84ObSdBeChT/AXYFA==
dependencies:
"@project-serum/borsh" "^0.2.2"
"@solana/web3.js" "^1.17.0"
base64-js "^1.5.1"
bn.js "^5.1.2"
bs58 "^4.0.1"
buffer-layout "^1.2.0"
buffer-layout "^1.2.2"
camelcase "^5.3.1"
crypto-hash "^1.3.0"
eventemitter3 "^4.0.7"
Expand Down Expand Up @@ -1536,7 +1536,7 @@ buffer-from@1.x, buffer-from@^1.0.0:
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5"
integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==

buffer-layout@^1.2.0:
buffer-layout@^1.2.0, buffer-layout@^1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/buffer-layout/-/buffer-layout-1.2.2.tgz#b9814e7c7235783085f9ca4966a0cfff112259d5"
integrity sha512-kWSuLN694+KTk8SrYvCqwP2WcgQjoRCiF5b4QDvkkz8EmgD+aWAIceGFKMIAdmF/pH+vpgNV3d3kAKorcdAmWA==
Expand Down
Loading