diff --git a/.travis.yml b/.travis.yml index 25cee9a..1fe8cc1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,14 +5,14 @@ rust: env: global: - NODE_VERSION="v14.7.0" - - SOLANA_VERSION="v1.6.6" - - ANCHOR_VERSION="v0.6.0" + - SOLANA_VERSION="v1.7.8" + - ANCHOR_VERSION="v0.13.0" before_deploy: - anchor build --verifiable - echo "### SHA256 Checksums" > release_notes.md - - sha256sum target/deploy/multisig.so > binary.txt - - sha256sum target/idl/multisig.json > idl.txt + - sha256sum target/deploy/serum_multisig.so > binary.txt + - sha256sum target/idl/serum_multisig.json > idl.txt - cat *.txt >> release_notes.md - echo "" >> release_notes.md - echo "Built with Anchor [${ANCHOR_VERSION}](https://github.com/project-serum/anchor/releases/tag/${ANCHOR_VERSION})." >> release_notes.md @@ -21,8 +21,8 @@ deploy: provider: releases edge: true file: - - "target/deploy/multisig.so" - - "target/idl/multisig.json" + - "target/deploy/serum_multisig.so" + - "target/idl/serum_multisig.json" release_notes_file: release_notes.md skip_cleanup: true on: diff --git a/Anchor.toml b/Anchor.toml index 0291187..4faca71 100644 --- a/Anchor.toml +++ b/Anchor.toml @@ -1,9 +1,14 @@ +anchor_version = "0.13.0" + [provider] cluster = "localnet" wallet = "~/.config/solana/id.json" -[clusters.devnet] -multisig = "F3Uf5F61dmht1xuNNNkk3jnzj82TY56vVjVEhZALRkN" +[programs.devnet] +serum_multisig = "F3Uf5F61dmht1xuNNNkk3jnzj82TY56vVjVEhZALRkN" + +[programs.mainnet] +serum_multisig = { address = "A9HAbnCwoD6f2NkZobKFf6buJoN9gUVVvX5PoUnDHS6u", path = "./target/deploy/serum_multisig.so", idl = "./target/idl/serum_multisig.json" } -[clusters.mainnet] -multisig = "A9HAbnCwoD6f2NkZobKFf6buJoN9gUVVvX5PoUnDHS6u" +[scripts] +test = "mocha -t 1000000 tests/" diff --git a/Cargo.lock b/Cargo.lock index 8c6d01b..9ad9ea4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "ahash" version = "0.4.7" @@ -17,9 +19,9 @@ dependencies = [ [[package]] name = "anchor-attribute-access-control" -version = "0.4.4" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bc1dd0644b68afc0d1debbb97ccb7f5f25f54616c705be67d54e434f2d272e0" +checksum = "317ec4ca2285689c98600f371a206105613ff0a614fb906403a8293b8d265fdf" dependencies = [ "anchor-syn", "anyhow", @@ -31,9 +33,9 @@ dependencies = [ [[package]] name = "anchor-attribute-account" -version = "0.4.4" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b758125edf97f9d5ba84b58bbd5a71b242847f049e648b6292887ab3541f8d1" +checksum = "7d9c7955ae7f81ac15b1da0fd5121a664161014183d5f33d13c6bed252b48af8" dependencies = [ "anchor-syn", "anyhow", @@ -44,9 +46,9 @@ dependencies = [ [[package]] name = "anchor-attribute-error" -version = "0.4.4" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "843a945ad0a288f5706090c20708ae910c1515fc103ab5fb1063f64e4be5a3a4" +checksum = "6a18ead124777eeee2afd09006c1814ded41c6d19422a56b91d2a0bc35a5c08e" dependencies = [ "anchor-syn", "proc-macro2", @@ -56,9 +58,9 @@ dependencies = [ [[package]] name = "anchor-attribute-event" -version = "0.4.4" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4f823d51a37431cd0a71864550104a1aa62b0f67d62612c90fa2ed0f96d4be1" +checksum = "2f46254314ed9da3c8913dcbdcd0130dc7a3e8bbedd14f4a7d0d9de825844f5e" dependencies = [ "anchor-syn", "anyhow", @@ -69,9 +71,9 @@ dependencies = [ [[package]] name = "anchor-attribute-interface" -version = "0.4.4" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca690936e1003978c354020da66b430769bbd17f3b31cae1aa5084a53132fc33" +checksum = "d116d72c20a6fe9fde7731cf83b0cd8af35afba4f4ef905374388e5e57567bdc" dependencies = [ "anchor-syn", "anyhow", @@ -83,9 +85,9 @@ dependencies = [ [[package]] name = "anchor-attribute-program" -version = "0.4.4" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af392df4e4b390d2b0438c7fb1fce1f4878a1acfb79791db29a78d5f41d684f8" +checksum = "211418fd8bdec824882fad89cc89af09b6d7360f61b283a518b6d4ca967631df" dependencies = [ "anchor-syn", "anyhow", @@ -96,9 +98,9 @@ dependencies = [ [[package]] name = "anchor-attribute-state" -version = "0.4.4" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa2b80913fa00d6df180f22e35a536d2d516dc786177198e40a4f8c6dc28f24b" +checksum = "99e5f39d6a3f6a3de5612079b56de0624c3c37c3b322b98508b26c0501d34b23" dependencies = [ "anchor-syn", "anyhow", @@ -109,9 +111,9 @@ dependencies = [ [[package]] name = "anchor-derive-accounts" -version = "0.4.4" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecb6f8805e1c705525d7c11a6f48d972d9a5d339bc98fa5e8ae24a7f0a8e4802" +checksum = "3b48d4574fd51e47c23e3621865fd753d8379f8d8217988e38a458b97e298d9c" dependencies = [ "anchor-syn", "anyhow", @@ -122,9 +124,9 @@ dependencies = [ [[package]] name = "anchor-lang" -version = "0.4.4" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b509f2f53910f0462f3acecb15a9d409ca346c1283214293113824f180ef75f8" +checksum = "011bb8da56486474f058c42c2c505f6cc995da0dd8a261dfd4bc7e4923a0380d" dependencies = [ "anchor-attribute-access-control", "anchor-attribute-account", @@ -134,7 +136,7 @@ dependencies = [ "anchor-attribute-program", "anchor-attribute-state", "anchor-derive-accounts", - "base64", + "base64 0.13.0", "borsh", "bytemuck", "solana-program", @@ -143,14 +145,15 @@ dependencies = [ [[package]] name = "anchor-syn" -version = "0.4.4" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65c19efff3d8def89fe320965d058bcaf05043f389182666859d626675875926" +checksum = "ed39067f714dc11cfd1096140f4cc2bdff1e5b1b0573bdd12c3ad5eba6ec9705" dependencies = [ "anyhow", "bs58", "heck", "proc-macro2", + "proc-macro2-diagnostics", "quote", "serde", "serde_json", @@ -194,6 +197,12 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +[[package]] +name = "base64" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" + [[package]] name = "base64" version = "0.13.0" @@ -231,14 +240,21 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ + "block-padding", "generic-array 0.14.4", ] +[[package]] +name = "block-padding" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" + [[package]] name = "borsh" -version = "0.8.2" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09a7111f797cc721407885a323fb071636aee57f750b1a4ddc27397eba168a74" +checksum = "18dda7dc709193c0d86a1a51050a926dc3df1cf262ec46a23a25dba421ea1924" dependencies = [ "borsh-derive", "hashbrown", @@ -246,9 +262,9 @@ dependencies = [ [[package]] name = "borsh-derive" -version = "0.8.2" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "307f3740906bac2c118a8122fe22681232b244f1369273e45f1156b45c43d2dd" +checksum = "684155372435f578c0fa1acd13ebbb182cc19d6b38b64ae7901da4393217d264" dependencies = [ "borsh-derive-internal", "borsh-schema-derive-internal", @@ -259,9 +275,9 @@ dependencies = [ [[package]] name = "borsh-derive-internal" -version = "0.8.2" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2104c73179359431cc98e016998f2f23bc7a05bc53e79741bcba705f30047bc" +checksum = "2102f62f8b6d3edeab871830782285b64cc1830168094db05c8e458f209bc5c3" dependencies = [ "proc-macro2", "quote", @@ -270,9 +286,9 @@ dependencies = [ [[package]] name = "borsh-schema-derive-internal" -version = "0.8.2" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae29eb8418fcd46f723f8691a2ac06857d31179d33d2f2d91eb13967de97c728" +checksum = "196c978c4c9b0b142d446ef3240690bf5a8a33497074a113ff9a337ccb750483" dependencies = [ "proc-macro2", "quote", @@ -337,6 +353,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + [[package]] name = "crypto-mac" version = "0.8.0" @@ -467,6 +489,27 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hmac" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840" +dependencies = [ + "crypto-mac", + "digest 0.9.0", +] + +[[package]] +name = "hmac-drbg" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" +dependencies = [ + "digest 0.9.0", + "generic-array 0.14.4", + "hmac", +] + [[package]] name = "humantime" version = "2.1.0" @@ -488,6 +531,12 @@ version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" +[[package]] +name = "keccak" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" + [[package]] name = "lazy_static" version = "1.4.0" @@ -500,6 +549,54 @@ version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03b07a082330a35e43f63177cc01689da34fbffa0105e1246cf0311472cac73a" +[[package]] +name = "libsecp256k1" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd1137239ab33b41aa9637a88a28249e5e70c40a42ccc92db7f12cc356c1fcd7" +dependencies = [ + "arrayref", + "base64 0.12.3", + "digest 0.9.0", + "hmac-drbg", + "libsecp256k1-core", + "libsecp256k1-gen-ecmult", + "libsecp256k1-gen-genmult", + "rand", + "serde", + "sha2", + "typenum", +] + +[[package]] +name = "libsecp256k1-core" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0f6ab710cec28cef759c5f18671a27dae2a5f952cdaaee1d8e2908cb2478a80" +dependencies = [ + "crunchy", + "digest 0.9.0", + "subtle", +] + +[[package]] +name = "libsecp256k1-gen-ecmult" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccab96b584d38fac86a83f07e659f0deafd0253dc096dab5a36d53efe653c5c3" +dependencies = [ + "libsecp256k1-core", +] + +[[package]] +name = "libsecp256k1-gen-genmult" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67abfe149395e3aa1c48a2beb32b068e2334402df8181f818d3aee2b304c4f5d" +dependencies = [ + "libsecp256k1-core", +] + [[package]] name = "log" version = "0.4.14" @@ -524,13 +621,6 @@ dependencies = [ "libc", ] -[[package]] -name = "multisig" -version = "0.4.0" -dependencies = [ - "anchor-lang", -] - [[package]] name = "num-derive" version = "0.3.3" @@ -587,6 +677,19 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "proc-macro2-diagnostics" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bf29726d67464d49fa6224a1d07936a8c08bb3fba727c7493f6cf1616fdaada" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "version_check", + "yansi", +] + [[package]] name = "quote" version = "1.0.9" @@ -731,6 +834,13 @@ dependencies = [ "serde", ] +[[package]] +name = "serum-multisig" +version = "0.5.0" +dependencies = [ + "anchor-lang", +] + [[package]] name = "sha2" version = "0.9.3" @@ -744,11 +854,23 @@ dependencies = [ "opaque-debug", ] +[[package]] +name = "sha3" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f81199417d4e5de3f04b1e871023acea7389672c4135918f05aa9cbf2f2fa809" +dependencies = [ + "block-buffer", + "digest 0.9.0", + "keccak", + "opaque-debug", +] + [[package]] name = "solana-frozen-abi" -version = "1.6.6" +version = "1.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10272e9486b3cb41b04e899929c521c5c2a037ba6be1651cff68ad3959f4d1f9" +checksum = "45c6760c1dd139c202ef6df28bff467c904aa35b1aa1a59be268c47aec8bc6c0" dependencies = [ "bs58", "bv", @@ -766,11 +888,10 @@ dependencies = [ [[package]] name = "solana-frozen-abi-macro" -version = "1.6.6" +version = "1.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82f4b6a34f19cc4b09da1919ff9810c1a499c7e77fc9d26bea022f69dc965edf" +checksum = "a4dbe296c16dec41e8e6f4e6c2694c6224820d34c0ab11a2d3ff9683f44878ef" dependencies = [ - "lazy_static", "proc-macro2", "quote", "rustc_version", @@ -779,9 +900,9 @@ dependencies = [ [[package]] name = "solana-logger" -version = "1.6.6" +version = "1.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c17fa89f2e5fe988cf95a34df411950db4609f68af8df602371d9b7f83cefa7" +checksum = "80af1959b520c0fc99bc6583ba9d82bfa15b1ac007516795bceeb4a951af77c7" dependencies = [ "env_logger", "lazy_static", @@ -790,9 +911,9 @@ dependencies = [ [[package]] name = "solana-program" -version = "1.6.6" +version = "1.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "885552ce43e9f2cf13fda274bf2b4ef75c5de6e5e0190f53acb83f84cda739c0" +checksum = "fe5e5dd99d642b5e89eeb20457310c3c23f20dbf44e67c64e473a02fbc50d646" dependencies = [ "bincode", "blake3", @@ -804,6 +925,7 @@ dependencies = [ "hex", "itertools", "lazy_static", + "libsecp256k1", "log", "num-derive", "num-traits", @@ -814,6 +936,7 @@ dependencies = [ "serde_bytes", "serde_derive", "sha2", + "sha3", "solana-frozen-abi", "solana-frozen-abi-macro", "solana-logger", @@ -823,9 +946,9 @@ dependencies = [ [[package]] name = "solana-sdk-macro" -version = "1.6.6" +version = "1.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8264149655cbbcfa1dccd0dc9f62eb04d6832ec08540fcb81db6f305a21d3b65" +checksum = "fee909dcddb5b4d349b3e5e1ae92f6660cd2f783dea392ae2e73210776aadc9b" dependencies = [ "bs58", "proc-macro2", @@ -959,6 +1082,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "yansi" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fc79f4a1e39857fc00c3f662cbf2651c771f00e9c15fe2abc341806bd46bd71" + [[package]] name = "zeroize" version = "1.2.0" diff --git a/programs/multisig/Cargo.toml b/programs/multisig/Cargo.toml index 12170d5..7802065 100644 --- a/programs/multisig/Cargo.toml +++ b/programs/multisig/Cargo.toml @@ -1,12 +1,12 @@ [package] -name = "multisig" -version = "0.4.0" +name = "serum-multisig" +version = "0.5.0" description = "Created with Anchor" edition = "2018" [lib] crate-type = ["cdylib", "lib"] -name = "multisig" +name = "serum_multisig" [features] no-entrypoint = [] @@ -15,4 +15,4 @@ cpi = ["no-entrypoint"] default = [] [dependencies] -anchor-lang = "0.6.0" +anchor-lang = "0.13.0" diff --git a/programs/multisig/src/lib.rs b/programs/multisig/src/lib.rs index b93c484..f1949d7 100644 --- a/programs/multisig/src/lib.rs +++ b/programs/multisig/src/lib.rs @@ -23,7 +23,7 @@ use anchor_lang::solana_program::instruction::Instruction; use std::convert::Into; #[program] -pub mod multisig { +pub mod serum_multisig { use super::*; // Initializes a new multisig account with a set of owners and a threshold. @@ -195,9 +195,9 @@ pub struct CreateTransaction<'info> { #[derive(Accounts)] pub struct Approve<'info> { - #[account("multisig.owner_set_seqno == transaction.owner_set_seqno")] + #[account(constraint = multisig.owner_set_seqno == transaction.owner_set_seqno)] multisig: ProgramAccount<'info, Multisig>, - #[account(mut, belongs_to = multisig)] + #[account(mut, has_one = multisig)] transaction: ProgramAccount<'info, Transaction>, // One of the multisig owners. Checked in the handler. #[account(signer)] @@ -217,14 +217,14 @@ pub struct Auth<'info> { #[derive(Accounts)] pub struct ExecuteTransaction<'info> { - #[account("multisig.owner_set_seqno == transaction.owner_set_seqno")] + #[account(constraint = multisig.owner_set_seqno == transaction.owner_set_seqno)] multisig: ProgramAccount<'info, Multisig>, #[account(seeds = [ multisig.to_account_info().key.as_ref(), &[multisig.nonce], ])] multisig_signer: AccountInfo<'info>, - #[account(mut, belongs_to = multisig)] + #[account(mut, has_one = multisig)] transaction: ProgramAccount<'info, Transaction>, } diff --git a/tests/multisig.js b/tests/multisig.js index e70edc3..24959a7 100644 --- a/tests/multisig.js +++ b/tests/multisig.js @@ -5,7 +5,7 @@ describe("multisig", () => { // Configure the client to use the local cluster. anchor.setProvider(anchor.Provider.env()); - const program = anchor.workspace.Multisig; + const program = anchor.workspace.SerumMultisig; it("Tests the multisig program", async () => { const multisig = anchor.web3.Keypair.generate(); @@ -39,7 +39,7 @@ describe("multisig", () => { signers: [multisig], }); - let multisigAccount = await program.account.multisig(multisig.publicKey); + let multisigAccount = await program.account.multisig.fetch(multisig.publicKey); assert.strictEqual(multisigAccount.nonce, nonce); assert.ok(multisigAccount.threshold.eq(new anchor.BN(2))); assert.deepStrictEqual(multisigAccount.owners, owners); @@ -81,7 +81,7 @@ describe("multisig", () => { signers: [transaction, ownerA], }); - const txAccount = await program.account.transaction(transaction.publicKey); + const txAccount = await program.account.transaction.fetch(transaction.publicKey); assert.ok(txAccount.programId.equals(pid)); assert.deepStrictEqual(txAccount.accounts, accounts); @@ -125,7 +125,7 @@ describe("multisig", () => { }), }); - multisigAccount = await program.account.multisig(multisig.publicKey); + multisigAccount = await program.account.multisig.fetch(multisig.publicKey); assert.strictEqual(multisigAccount.nonce, nonce); assert.ok(multisigAccount.threshold.eq(new anchor.BN(2)));