From ead0f460e572f72e79dedb7b441f6667558dbb89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Flak?= Date: Tue, 9 Aug 2022 16:38:44 +0200 Subject: [PATCH 01/48] Try and run action --- .base-ammanrc.js | 5 + .../actions/yarn-install-and-build/action.yml | 14 ++ .../workflows/integration-auction-house.yml | 78 +++++++++++ Cargo.toml | 4 +- .../js/test/integration.auction-house.test.js | 15 +++ auction-house/js/test/utils.ts | 125 ++++++++++++++++++ 6 files changed, 239 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/integration-auction-house.yml create mode 100644 auction-house/js/test/integration.auction-house.test.js create mode 100644 auction-house/js/test/utils.ts diff --git a/.base-ammanrc.js b/.base-ammanrc.js index 25fef75411..88b54423ad 100644 --- a/.base-ammanrc.js +++ b/.base-ammanrc.js @@ -40,6 +40,11 @@ const programs = { programId: 'cndy3Z4yapfJBmL3ShUp5exZKqR3z33thTzeNMm2gRZ', deployPath: localDeployPath('mpl_candy_machine'), }, + auction_house: { + label: "Auction House", + programId: 'hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk', + deployPath: localDeployPath('mpl_auction_house'), + }, }; const validator = { diff --git a/.github/actions/yarn-install-and-build/action.yml b/.github/actions/yarn-install-and-build/action.yml index 7291cf11cd..2cf356a884 100644 --- a/.github/actions/yarn-install-and-build/action.yml +++ b/.github/actions/yarn-install-and-build/action.yml @@ -24,6 +24,10 @@ inputs: description: If true it will build the token_vault package required: false default: false + build_auction_house: + description: If true it will build the auction_house package + required: false + default: false runs: using: composite @@ -83,6 +87,16 @@ runs: working-directory: ./token-vault/js shell: bash + - name: Install and Build auction-house + if: inputs.build_auction_house == 'true' + run: | + echo 'Install and Build auction_house: yarn install' + yarn install + echo 'Install and Build auction_house: yarn build' + yarn build + working-directory: ./auction_house/js + shell: bash + ############## # Build Contract ############## diff --git a/.github/workflows/integration-auction-house.yml b/.github/workflows/integration-auction-house.yml new file mode 100644 index 0000000000..0410b682f8 --- /dev/null +++ b/.github/workflows/integration-auction-house.yml @@ -0,0 +1,78 @@ +name: Integration Auction House + +on: + push: + branches: [master] + pull_request: + branches: [master] + +env: + CARGO_TERM_COLOR: always + SOLANA_VERSION: 1.9.14 + RUST_TOOLCHAIN: stable + +jobs: + changes: + runs-on: ubuntu-latest + # Set job outputs to values from filter step + outputs: + core: ${{ steps.filter.outputs.core }} + package: ${{ steps.filter.outputs.package }} + steps: + - uses: actions/checkout@v2 + # For pull requests it's not necessary to checkout the code + - uses: dorny/paths-filter@v2 + id: filter + with: + filters: | + core: + - 'core/**' + package: + - 'auction-house/**' + build-and-integration-test-auction-house: + runs-on: ubuntu-latest + env: + cache_id: program-auction-house + needs: changes + if: ${{ needs.changes.outputs.core == 'true' || needs.changes.outputs.package == 'true' }} + steps: + # Setup Deps + - uses: actions/checkout@v2 + - uses: ./.github/actions/install-linux-build-deps + - uses: ./.github/actions/install-solana + with: + solana_version: ${{ env.SOLANA_VERSION }} + - uses: ./.github/actions/install-rust + with: + toolchain: ${{ env.RUST_TOOLCHAIN }} + + # Restore Cache from previous build/test + - uses: actions/cache@v2 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + ./rust/target + key: ${{ env.cache_id }}-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ env.RUSTC_HASH }} + + # Build Rust Programs + - uses: ./.github/actions/build-auction-house + + # Install JS SDK deps + - uses: ./.github/actions/yarn-install-and-build + with: + cache_id: sdk-auction-house + working_dir: ./auction-house/js + build_auction_house: true + + # Run integration test + - name: start-local-test-validator + working-directory: ./auction-house/js + run: DEBUG=amman* yarn amman:start + + - name: integration-test-auction-house-program + id: run_integration_test + working-directory: ./auction-house/js + run: DEBUG=mpl* yarn test diff --git a/Cargo.toml b/Cargo.toml index f0ff6cb8b8..0f5391b9b5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,11 +6,11 @@ members=[ "token-vault/program", "token-vault/test", "nft-packs/program", - "fixed-price-sale/program" + "fixed-price-sale/program", ] exclude = [ "fixed-price-sale/cli", + "candy-machine/program", "token-metadata", "auction-house/program", - "candy-machine/program" ] diff --git a/auction-house/js/test/integration.auction-house.test.js b/auction-house/js/test/integration.auction-house.test.js new file mode 100644 index 0000000000..e1bdd62937 --- /dev/null +++ b/auction-house/js/test/integration.auction-house.test.js @@ -0,0 +1,15 @@ +import test from 'tape'; +import { SetStore } from '../src/transactions'; +import { Store } from '../src/accounts/Store'; +import { connectionURL } from './utils'; +import { Connection, Keypair, PublicKey } from '@solana/web3.js'; +import { airdrop, PayerTransactionHandler } from '@metaplex-foundation/amman'; + +test('test_action', async (t) => { + const payer = Keypair.generate(); + const connection = new Connection(connectionURL, 'confirmed'); + const transactionHandler = new PayerTransactionHandler(connection, payer); + await airdrop(connection, payer.publicKey, 2); + + t.ok(True, 'Test runs'); +}); diff --git a/auction-house/js/test/utils.ts b/auction-house/js/test/utils.ts new file mode 100644 index 0000000000..2a8f9610f7 --- /dev/null +++ b/auction-house/js/test/utils.ts @@ -0,0 +1,125 @@ +import path from 'path'; +import { Keypair, PublicKey, TransactionCtorFields } from '@solana/web3.js'; +import { tmpdir } from 'os'; +import { readFileSync } from 'fs'; +import { LOCALHOST } from '@metaplex-foundation/amman'; + +export const connectionURL = LOCALHOST; + +// Devnet fee payer +export const FEE_PAYER = Keypair.fromSecretKey( + new Uint8Array([ + 225, 60, 117, 68, 123, 252, 1, 200, 41, 251, 54, 121, 6, 167, 204, 18, 140, 168, 206, 74, 254, + 156, 230, 10, 212, 124, 162, 85, 120, 78, 122, 106, 187, 209, 148, 182, 34, 149, 175, 173, 192, + 85, 175, 252, 231, 130, 76, 40, 175, 177, 44, 111, 250, 168, 3, 236, 149, 34, 236, 19, 46, 9, + 66, 138, + ]), +); + +export const STORE_OWNER_PUBKEY = new PublicKey('7hKMAoCYJuBnBLmVTjswu7m6jcwyE8MYAP5hPijUT6nd'); +export const STORE_PUBKEY = new PublicKey('DNQzo4Aggw8PneX7BGY7niEkB8wfNJwx6DpV9BLBUUFF'); +export const AUCTION_MANAGER_PUBKEY = new PublicKey('Gjd1Mo8KLEgywxMKaDRhaoD2Fu8bzoVLZ8H7v761XXkf'); +export const AUCTION_PUBKEY = new PublicKey('BTE7AqJn4aG2MKZnaSTEgbQ4aCgPTDmphs5uxDnuDqvQ'); +export const AUCTION_EXTENDED_PUBKEY = new PublicKey( + '9nUKpweEWpk5mQiBzxYWB62dhQR5NtaZDShccqsWnPGa', +); +export const VAULT_PUBKEY = new PublicKey('BE43QppYzwWVVSobScMbPgqKogPHsHQoogXgLH3ZTFtW'); +export const METADATA_PUBKEY = new PublicKey('CZkFeERacU42qjApPyjamS13fNtz7y1wYLu5jyLpN1WL'); +export const MASTER_EDITION_PUBKEY = new PublicKey('EZ5xB174dcz982WXV2aNr4zSW5ywAH3gP5Lbj8CuRMw4'); +export const PACKSET_PUBKEY = new PublicKey('AN1bTGLCLSoSTJMeBPa7KGRDF5BpbfvD7oA42ZMq27Ru'); +export const PACKCARD_PUBKEY = new PublicKey('BVrBhek71ZDDPQ8tYucBiEKxYmmtQLioF3eJJnhH6md4'); +export const PACKVOUCHER_PUBKEY = new PublicKey('Ah6ngnNfhzKFfMPtiK5BeQ4mF5Nzwv1bwtbAEgMYH6Dp'); +export const PROVING_PROCESS_PUBKEY = new PublicKey('HCzXvi3L1xdkFp5jafadFGzbirua9U4r4ePiXvcqH81R'); + +export const VAULT_AUTHORITY_PUBKEY = new PublicKey('AHsj4FffgTUYUVDjwBRGmiAsJcpWxX3YXZB8qsuew79t'); +export const FRACTIONAL_MINT_PUBKEY = new PublicKey('1Qyhk9Pm1XktCN8RptQrwe9KnQLmiD7E58LpvqcnSV8'); +export const REDEEM_TREASURY_PUBKEY = new PublicKey('vkXyVgeQaivApFsUXLMcQcVK7FGzkhAyR73FJ5YGnnb'); +export const FRACTIONAL_TREASURY_PUBKEY = new PublicKey( + '5nxC9KnUSqr5dNQoPN7xhKfmzS48znM3zfNqcgdKYXrh', +); +export const PRICING_LOOKUP_ADDRESS_PUBKEY = new PublicKey( + '7csPZBkT87N7x7aVrALjLBeDjCs7vcymazXVxoS3fmSf', +); +export const FRACTION_MINT_PUBKEY = new PublicKey('BjrKGZgGL7sqv5aAUxp6ZafsWGKku9UZcMioQqASSaFB'); +export const FRACTION_TREASURY_PUBKEY = new PublicKey( + '3SZUEd9qtoKCyLW8uT8z25k7kZnMmwtdLQYjQAYRZHRp', +); +export const FRACTION_MINT_AUTHORITY_PUBKEY = new PublicKey( + '693Dn6MCsBYS4SkpSAXdhEvWNDooUHyF8KvvniEy4aBM', +); +export const TOKEN_MINT_PUBKEY = new PublicKey('8epm7eTwoEpw36QF1puxkzsRzkVp45paRXnohbPemjmK'); +export const TOKEN_ACCOUNT_PUBKEY = new PublicKey('4mpzrMQo8wgBtUHDVZLPeR9i58mbHVFNT9ef8sSzUohS'); +export const TOKEN_STORE_ACCOUNT_PUBKEY = new PublicKey( + 'B8ZH2ndZk1ueJvu56UNThAdjGXkfs1PyC5DwupWbwfZ3', +); +export const TRANSFER_AUTHORITY_PUBKEY = new PublicKey( + '8azYDQNycrRkv2r7amatTy3dyD6RrSw3zZsJvymzWE3E', +); +export const SAFETY_DEPOSIT_BOX_PUBKEY = new PublicKey( + '7pgXQDqVpiuj7TqbJKn9bW7ipg8U2uG5kY7kXNdNiTQd', +); +export const OUTSTANDING_SHARE_TOKEN_ACCOUNT_PUBKEY = new PublicKey( + '5Q9THrE74FsopHjASfj7RLqR36RgYbKhD1shoPoDDCCZ', +); +export const OUTSTANDING_SHARES_ACCOUNT_PUBKEY = new PublicKey( + '4Q2A27cS5DihPnerndsFZ6MxSTzjzfsjuQtS2hV3VXTT', +); +export const BURN_AUTHORITY_PUBKEY = new PublicKey('4d4xRorridzBRApmoprSaB74Tgv4TN7TqhqfUeQB2dvw'); +export const NEW_VAULT_AUTHORITY_PUBKEY = new PublicKey( + 'Hi4wFQcmHKioVKvsL3NeYy9gANkZF9RQ9ZvTU7FdHP9s', +); +export const EXTERNAL_PRICE_ACCOUNT_PUBKEY = new PublicKey( + '78qz3gehg9YqktdaYt6o56DSUPFQ41tLMACHpnFjdYdS', +); +export const PAYING_TOKEN_ACCOUNT_PUBKEY = new PublicKey( + '8e6FHYEx7rfv1weRKrerjwuDzVn89LSjDsfXZcvWYDYW', +); +export const CURRENT_AUTHORITY_PUBKEY = new PublicKey( + 'EyBYD5b1A2xQAHJ8nUn11nHY8VrPV3Scg4mXZyjCB61f', +); +export const NEW_AUTHORITY_PUBKEY = new PublicKey('5jF6nAQ5GTK8rsdzW8hGCEsWjY9YCV2jXCwZ854BPsWz'); +export const RECENT_ISH_BLOCKHASH = '9qb2wMGnvBgVdp2dhJdeo5hgko9nLHxXg7GqXPgAFYCU'; +export const PROCEEDS_ACCOUNT_PUBKEY = new PublicKey( + 'GvJVHbk8pEzHwaeHeaoUrnBbsaUcDHHRVjKqP15UcShf', +); +export const SOURCE_PUBKEY = new PublicKey('4CkQJBxhU8EZ2UjhigbtdaPbpTe6mqf811fipYBFbSYN'); +export const DESTINATION_PUBKEY = new PublicKey('CZXESU6tu9m4YDs2wfQFbXmjbaDtJKBgurgYzGmeoArh'); + +export const VAULT_EXTENRNAL_PRICE_ACCOUNT = new PublicKey( + '58S2MNcuS79ncBc5xi1T8jdS98jcXJbXqM5UvGvgmwcr', +); + +export const mockTransaction: TransactionCtorFields = { + feePayer: new PublicKey('7J6QvJGCB22vDvYB33ikrWCXRBRsFY74ntAArSK4KJUn'), + recentBlockhash: RECENT_ISH_BLOCKHASH, +}; +export const BID_METADATA_PUBKEY = new PublicKey('CZkFeERacU42qjGTPyjamS13fNtz7y1wYLu5jyLpN1WL'); +export const BID_REDEMPTION_PUBKEY = new PublicKey('4CkQJBxhU8EZ1UjhfgbtdaPbpTe6mqf811fipYBFbSYN'); +export const SAFETY_DEPOSIT_TOKEN_STORE_PUBKEY = new PublicKey( + '4CkQJBxhU8EZ1UjhfgbtdaPbpTe6mqf811fipYBFbSNM', +); +export const SAFETY_DEPOSIT_CONFIG_PUBKEY = new PublicKey( + '4CkBUBxhU8EZ1UjhfgbtdaPbpTe6mqf811fipYBFbSNM', +); +export const NEW_EDITION_PUBKEY = new PublicKey('4CkBUBxhU8EZ1UjhfgbtdaPbpTe6mqf822fipYBFbSNM'); +export const NEW_METADATA_PUBKEY = new PublicKey('5jF6nAQ5GTK8rsdzW8hGCEsWjY9YCV2jXCwZ111BPsWz'); +export const EDITION_MARK_PUBKEY = new PublicKey('78qz3gehg9YqktdaYt6o71DSUPFQ41tLMACHpnFjdYdS'); +export const PRIZE_TRACKING_TICKET_PUBKEY = new PublicKey( + '78qz3gehg9YqktdaYt6o99DSUPFQ41tLMACHpnFjdYdS', +); + +export const projectRoot = path.resolve(__dirname, '..', '..'); +export const tmpTestDir = path.resolve(tmpdir(), 'test'); + +export const serializeConfig = { verifySignatures: false, requireAllSignatures: false }; +export async function sleep(ms: number) { + return new Promise((resolve) => setTimeout(resolve, ms)); +} + +export function getUserKeypairFromFile(keypairPath: string) { + const arr = readFileSync(path.resolve(keypairPath), { + encoding: 'utf-8', + }); + const u8Array = Uint8Array.from(JSON.parse(arr)); + return Keypair.fromSecretKey(u8Array); +} From 8bc7fdeaa6ac14a0873c23ec9498b96e46de7eb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Flak?= Date: Tue, 9 Aug 2022 19:03:11 +0200 Subject: [PATCH 02/48] fix path --- .github/actions/yarn-install-and-build/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/yarn-install-and-build/action.yml b/.github/actions/yarn-install-and-build/action.yml index 2cf356a884..bacd207c31 100644 --- a/.github/actions/yarn-install-and-build/action.yml +++ b/.github/actions/yarn-install-and-build/action.yml @@ -94,7 +94,7 @@ runs: yarn install echo 'Install and Build auction_house: yarn build' yarn build - working-directory: ./auction_house/js + working-directory: ./auction-house/js shell: bash ############## From 36757e461a326d31effc31dde19434c5fbcdfae7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Flak?= Date: Tue, 9 Aug 2022 19:59:08 +0200 Subject: [PATCH 03/48] Add onchain / source integration test stub for AH --- .base-ammanrc.js | 1 + .../workflows/integration-auction-house.yml | 18 ++++++++++++++++++ auction-house/js/.ammanrc.js | 11 +++++++++++ auction-house/js/onchain.ammanrc.js | 19 +++++++++++++++++++ auction-house/js/package.json | 3 +++ 5 files changed, 52 insertions(+) create mode 100644 auction-house/js/.ammanrc.js create mode 100644 auction-house/js/onchain.ammanrc.js diff --git a/.base-ammanrc.js b/.base-ammanrc.js index 88b54423ad..fa1fa55716 100644 --- a/.base-ammanrc.js +++ b/.base-ammanrc.js @@ -48,6 +48,7 @@ const programs = { }; const validator = { + accountsCluster: 'https://api.metaplex.solana.com', killRunningValidators: true, programs, commitment: 'singleGossip', diff --git a/.github/workflows/integration-auction-house.yml b/.github/workflows/integration-auction-house.yml index 0410b682f8..59ba55580a 100644 --- a/.github/workflows/integration-auction-house.yml +++ b/.github/workflows/integration-auction-house.yml @@ -76,3 +76,21 @@ jobs: id: run_integration_test working-directory: ./auction-house/js run: DEBUG=mpl* yarn test + + - name: stop-local-test-validator + working-directory: ./auction-house/js + run: DEBUG=amman* yarn amman:stop + + # Run integration test - onchain program + - name: start-local-test-validator-onchain + working-directory: ./auction-house/js + run: DEBUG=amman* yarn amman:start onchain.ammanrc.js + + - name: integration-test-auction-house-program + id: run_integration_test + working-directory: ./auction-house/js + run: DEBUG=mpl* yarn test + + - name: stop-local-test-validator + working-directory: ./auction-house/js + run: DEBUG=amman* yarn amman:stop diff --git a/auction-house/js/.ammanrc.js b/auction-house/js/.ammanrc.js new file mode 100644 index 0000000000..e2b8c56755 --- /dev/null +++ b/auction-house/js/.ammanrc.js @@ -0,0 +1,11 @@ +'use strict'; +// @ts-check +const base = require('../../.base-ammanrc.js'); + +const validator = { + ...base.validator, + programs: [ + base.programs.auction_house, + ], +}; +module.exports = { validator }; diff --git a/auction-house/js/onchain.ammanrc.js b/auction-house/js/onchain.ammanrc.js new file mode 100644 index 0000000000..3a887615ea --- /dev/null +++ b/auction-house/js/onchain.ammanrc.js @@ -0,0 +1,19 @@ +'use strict'; +// @ts-check +const base = require('../../.base-ammanrc.js'); + +const accounts = { + auction_house: { + label: "Auction House", + programId: 'hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk', + executable: true, + }, +} + +const validator = { + ...base.validator, + programs: [], + accounts: accounts +}; + +module.exports = { validator }; diff --git a/auction-house/js/package.json b/auction-house/js/package.json index a618793450..09f481c7b5 100644 --- a/auction-house/js/package.json +++ b/auction-house/js/package.json @@ -13,6 +13,9 @@ "build:docs": "typedoc", "build": "rimraf dist && tsc -p tsconfig.json", "build:watch": "rimraf dist && tsc -p tsconfig.json --watch", + "amman:start": "DEBUG=\"amman*\" amman validator ${0}", + "amman:stop": "pkill solana-test-validator", + "test:all": "yarn build && yarn amman:start ${0} && yarn test", "test": "esr ./test/*.test.ts", "api:gen": "DEBUG='(solita|rustbin):(info|error)' solita", "lint": "eslint \"{src,test}/**/*.ts\" --format stylish", From be0a80b0dcfc0701383beb432cde035ffbb9dfef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Flak?= Date: Tue, 9 Aug 2022 20:12:38 +0200 Subject: [PATCH 04/48] Make ID unique --- .github/workflows/integration-auction-house.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration-auction-house.yml b/.github/workflows/integration-auction-house.yml index 59ba55580a..5f6d2bd033 100644 --- a/.github/workflows/integration-auction-house.yml +++ b/.github/workflows/integration-auction-house.yml @@ -87,7 +87,7 @@ jobs: run: DEBUG=amman* yarn amman:start onchain.ammanrc.js - name: integration-test-auction-house-program - id: run_integration_test + id: run_integration_test_onchain working-directory: ./auction-house/js run: DEBUG=mpl* yarn test From e8effcedeb90ecd7f5c21f7e086b265f5c02a93a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Flak?= Date: Tue, 9 Aug 2022 20:35:32 +0200 Subject: [PATCH 05/48] Unbound parameter fix --- .github/workflows/integration-auction-house.yml | 2 +- auction-house/js/package.json | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integration-auction-house.yml b/.github/workflows/integration-auction-house.yml index 5f6d2bd033..6cf9c02d74 100644 --- a/.github/workflows/integration-auction-house.yml +++ b/.github/workflows/integration-auction-house.yml @@ -84,7 +84,7 @@ jobs: # Run integration test - onchain program - name: start-local-test-validator-onchain working-directory: ./auction-house/js - run: DEBUG=amman* yarn amman:start onchain.ammanrc.js + run: DEBUG=amman* yarn amman:start-custom-ammanrc onchain.ammanrc.js - name: integration-test-auction-house-program id: run_integration_test_onchain diff --git a/auction-house/js/package.json b/auction-house/js/package.json index 09f481c7b5..e869698445 100644 --- a/auction-house/js/package.json +++ b/auction-house/js/package.json @@ -13,9 +13,11 @@ "build:docs": "typedoc", "build": "rimraf dist && tsc -p tsconfig.json", "build:watch": "rimraf dist && tsc -p tsconfig.json --watch", - "amman:start": "DEBUG=\"amman*\" amman validator ${0}", + "amman:start": "DEBUG=\"amman*\" amman validator", + "amman:start-custom-ammanrc": "DEBUG=\"amman*\" amman validator ${0}", "amman:stop": "pkill solana-test-validator", - "test:all": "yarn build && yarn amman:start ${0} && yarn test", + "test:all": "yarn build && yarn amman:start && yarn test", + "test:all-custom-ammanrc": "yarn build && yarn amman:start ${0} && yarn test", "test": "esr ./test/*.test.ts", "api:gen": "DEBUG='(solita|rustbin):(info|error)' solita", "lint": "eslint \"{src,test}/**/*.ts\" --format stylish", From 6feb0806d0d970fc842013b8a025838125bc6802 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Flak?= Date: Tue, 9 Aug 2022 21:29:40 +0200 Subject: [PATCH 06/48] Another try --- .base-ammanrc.js | 2 +- auction-house/js/package.json | 6 +- yarn.lock | 369 +++++++++++++++++++++++++++++++++- 3 files changed, 368 insertions(+), 9 deletions(-) diff --git a/.base-ammanrc.js b/.base-ammanrc.js index fa1fa55716..1e9d0cfbc0 100644 --- a/.base-ammanrc.js +++ b/.base-ammanrc.js @@ -43,7 +43,7 @@ const programs = { auction_house: { label: "Auction House", programId: 'hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk', - deployPath: localDeployPath('mpl_auction_house'), + deployPath: path.join(__dirname, 'auction-house', 'program', 'target', 'deploy') }, }; diff --git a/auction-house/js/package.json b/auction-house/js/package.json index e869698445..353e854e20 100644 --- a/auction-house/js/package.json +++ b/auction-house/js/package.json @@ -13,8 +13,8 @@ "build:docs": "typedoc", "build": "rimraf dist && tsc -p tsconfig.json", "build:watch": "rimraf dist && tsc -p tsconfig.json --watch", - "amman:start": "DEBUG=\"amman*\" amman validator", - "amman:start-custom-ammanrc": "DEBUG=\"amman*\" amman validator ${0}", + "amman:start": "DEBUG=\"amman*\" amman start", + "amman:start-custom-ammanrc": "DEBUG=\"amman*\" amman start ${0}", "amman:stop": "pkill solana-test-validator", "test:all": "yarn build && yarn amman:start && yarn test", "test:all-custom-ammanrc": "yarn build && yarn amman:start ${0} && yarn test", @@ -51,8 +51,10 @@ "bn.js": "^5.2.0" }, "devDependencies": { + "@metaplex-foundation/amman": "^0.10.0", "@metaplex-foundation/solita": "^0.5.0", "@types/tape": "^4.13.2", + "esbuild-runner": "^2.2.1", "eslint": "^8.3.0", "prettier": "^2.5.1", "rimraf": "^3.0.2", diff --git a/yarn.lock b/yarn.lock index 2add184381..0aee4aa778 100644 --- a/yarn.lock +++ b/yarn.lock @@ -922,6 +922,22 @@ __metadata: languageName: node linkType: hard +"@metaplex-foundation/amman-client@npm:^0.1.0": + version: 0.1.0 + resolution: "@metaplex-foundation/amman-client@npm:0.1.0" + dependencies: + "@metaplex-foundation/cusper": ^0.0.2 + "@solana/spl-token-registry": ^0.2.2405 + "@solana/web3.js": ^1.43.4 + bn.js: ^5.2.1 + debug: ^4.3.3 + js-sha3: ^0.8.0 + socket.io-client: ^4.4.1 + tweetnacl: ^1.0.3 + checksum: 8a5fca456a81cb5c0b27a04cf18fc49925bb09cdde6ec9b7d6424cab7f5cd49ebe1af7440f32c57adadd34e54c804f972c85d2db1a99b8447e01fdbe1a310298 + languageName: node + linkType: hard + "@metaplex-foundation/amman@npm:^0.1.0": version: 0.1.0 resolution: "@metaplex-foundation/amman@npm:0.1.0" @@ -940,6 +956,34 @@ __metadata: languageName: node linkType: hard +"@metaplex-foundation/amman@npm:^0.10.0": + version: 0.10.0 + resolution: "@metaplex-foundation/amman@npm:0.10.0" + dependencies: + "@metaplex-foundation/amman-client": ^0.1.0 + "@solana/spl-token": ^0.2.0 + "@solana/web3.js": ^1.43.4 + ansi-colors: ^4.1.1 + bn.js: ^5.2.0 + buffer-hexdump: ^1.0.0 + date-fns: ^2.28.0 + debug: ^4.3.3 + deep-diff: ^1.0.2 + diff: ^5.1.0 + numeral: ^2.0.6 + port-pid: ^0.0.7 + socket.io: ^4.4.1 + split2: ^4.1.0 + text-table: ^0.2.0 + timeago.js: ^4.0.2 + wait-on: ^6.0.0 + yargs: ^17.3.0 + bin: + amman: dist/cli/amman.js + checksum: ceefa1f6db040ceb8b0c423e46bbc1a28881e108c5b7bc6af1fd57315ba173d71d66605c94231cde08382b59dd3b02a3ecfda1835ab4dc1ad3186228a6fc8576 + languageName: node + linkType: hard + "@metaplex-foundation/beet-solana@npm:^0.1.1": version: 0.1.1 resolution: "@metaplex-foundation/beet-solana@npm:0.1.1" @@ -1022,6 +1066,7 @@ __metadata: version: 0.0.0-use.local resolution: "@metaplex-foundation/mpl-auction-house@workspace:auction-house/js" dependencies: + "@metaplex-foundation/amman": ^0.10.0 "@metaplex-foundation/beet": ^0.1.0 "@metaplex-foundation/beet-solana": ^0.1.1 "@metaplex-foundation/cusper": ^0.0.2 @@ -1029,6 +1074,7 @@ __metadata: "@solana/web3.js": ^1.35.1 "@types/tape": ^4.13.2 bn.js: ^5.2.0 + esbuild-runner: ^2.2.1 eslint: ^8.3.0 prettier: ^2.5.1 rimraf: ^3.0.2 @@ -1689,6 +1735,13 @@ __metadata: languageName: node linkType: hard +"@socket.io/component-emitter@npm:~3.1.0": + version: 3.1.0 + resolution: "@socket.io/component-emitter@npm:3.1.0" + checksum: db069d95425b419de1514dffe945cc439795f6a8ef5b9465715acf5b8b50798e2c91b8719cbf5434b3fe7de179d6cdcd503c277b7871cb3dd03febb69bdd50fa + languageName: node + linkType: hard + "@solana/buffer-layout-utils@npm:^0.2.0": version: 0.2.0 resolution: "@solana/buffer-layout-utils@npm:0.2.0" @@ -1770,6 +1823,31 @@ __metadata: languageName: node linkType: hard +"@solana/web3.js@npm:^1.43.4": + version: 1.50.1 + resolution: "@solana/web3.js@npm:1.50.1" + dependencies: + "@babel/runtime": ^7.12.5 + "@ethersproject/sha2": ^5.5.0 + "@solana/buffer-layout": ^4.0.0 + bigint-buffer: ^1.1.5 + bn.js: ^5.0.0 + borsh: ^0.7.0 + bs58: ^4.0.1 + buffer: 6.0.1 + fast-stable-stringify: ^1.0.0 + jayson: ^3.4.4 + js-sha3: ^0.8.0 + node-fetch: 2 + react-native-url-polyfill: ^1.3.0 + rpc-websockets: ^7.5.0 + secp256k1: ^4.0.2 + superstruct: ^0.14.2 + tweetnacl: ^1.0.0 + checksum: 49dca7b9caa776a6184b6008af74907d55b4dde3652babd066d316b585e00f7e2d63d1fb450b7a32591c371dfcee3d4bbfff98409ed80a07216a90dc58c7fb86 + languageName: node + linkType: hard + "@tootallnate/once@npm:1": version: 1.1.2 resolution: "@tootallnate/once@npm:1.1.2" @@ -1802,6 +1880,13 @@ __metadata: languageName: node linkType: hard +"@types/component-emitter@npm:^1.2.10": + version: 1.2.11 + resolution: "@types/component-emitter@npm:1.2.11" + checksum: 0e081c5f7a4b113af3732f67ad9ebb487d5c239d440d96938ff9a679d18bb9337a513638e12b5b02a7a921494eef18c5a4d78f1188bc43a12290edd74c42a9c7 + languageName: node + linkType: hard + "@types/connect@npm:^3.4.33": version: 3.4.35 resolution: "@types/connect@npm:3.4.35" @@ -1811,6 +1896,20 @@ __metadata: languageName: node linkType: hard +"@types/cookie@npm:^0.4.1": + version: 0.4.1 + resolution: "@types/cookie@npm:0.4.1" + checksum: 3275534ed69a76c68eb1a77d547d75f99fedc80befb75a3d1d03662fb08d697e6f8b1274e12af1a74c6896071b11510631ba891f64d30c78528d0ec45a9c1a18 + languageName: node + linkType: hard + +"@types/cors@npm:^2.8.12": + version: 2.8.12 + resolution: "@types/cors@npm:2.8.12" + checksum: 8c45f112c7d1d2d831b4b266f2e6ed33a1887a35dcbfe2a18b28370751fababb7cd045e745ef84a523c33a25932678097bf79afaa367c6cb3fa0daa7a6438257 + languageName: node + linkType: hard + "@types/debug@npm:^4.1.7": version: 4.1.7 resolution: "@types/debug@npm:4.1.7" @@ -1873,6 +1972,13 @@ __metadata: languageName: node linkType: hard +"@types/node@npm:>=10.0.0": + version: 18.6.5 + resolution: "@types/node@npm:18.6.5" + checksum: e3e66c9a84b94010a57c1b9dac882c08484278d74f9d120dbe6a3e45d00740d178bd1d34a5deee28197c94b9f4359153b637bab9b305328e865027e9987a0f3d + languageName: node + linkType: hard + "@types/node@npm:^12.12.54": version: 12.20.55 resolution: "@types/node@npm:12.20.55" @@ -2062,6 +2168,16 @@ __metadata: languageName: node linkType: hard +"accepts@npm:~1.3.4": + version: 1.3.8 + resolution: "accepts@npm:1.3.8" + dependencies: + mime-types: ~2.1.34 + negotiator: 0.6.3 + checksum: 50c43d32e7b50285ebe84b613ee4a3aa426715a7d131b65b786e2ead0fd76b6b60091b9916d3478a75f11f162628a2139991b6c03ab3f1d9ab7c86075dc8eab4 + languageName: node + linkType: hard + "acorn-jsx@npm:^5.3.2": version: 5.3.2 resolution: "acorn-jsx@npm:5.3.2" @@ -2129,6 +2245,13 @@ __metadata: languageName: node linkType: hard +"ansi-colors@npm:^4.1.1": + version: 4.1.3 + resolution: "ansi-colors@npm:4.1.3" + checksum: a9c2ec842038a1fabc7db9ece7d3177e2fe1c5dc6f0c51ecfbf5f39911427b89c00b5dc6b8bd95f82a26e9b16aaae2e83d45f060e98070ce4d1333038edceb0e + languageName: node + linkType: hard + "ansi-escapes@npm:^4.2.1": version: 4.3.2 resolution: "ansi-escapes@npm:4.3.2" @@ -2384,6 +2507,13 @@ __metadata: languageName: node linkType: hard +"base64id@npm:2.0.0, base64id@npm:~2.0.0": + version: 2.0.0 + resolution: "base64id@npm:2.0.0" + checksum: 581b1d37e6cf3738b7ccdd4d14fe2bfc5c238e696e2720ee6c44c183b838655842e22034e53ffd783f872a539915c51b0d4728a49c7cc678ac5a758e00d62168 + languageName: node + linkType: hard + "bcrypt-pbkdf@npm:^1.0.0": version: 1.0.2 resolution: "bcrypt-pbkdf@npm:1.0.2" @@ -2440,7 +2570,7 @@ __metadata: languageName: node linkType: hard -"bn.js@npm:^5.0.0, bn.js@npm:^5.1.0, bn.js@npm:^5.1.2, bn.js@npm:^5.2.0": +"bn.js@npm:^5.0.0, bn.js@npm:^5.1.0, bn.js@npm:^5.1.2, bn.js@npm:^5.2.0, bn.js@npm:^5.2.1": version: 5.2.1 resolution: "bn.js@npm:5.2.1" checksum: 3dd8c8d38055fedfa95c1d5fc3c99f8dd547b36287b37768db0abab3c239711f88ff58d18d155dd8ad902b0b0cee973747b7ae20ea12a09473272b0201c9edd3 @@ -2518,6 +2648,13 @@ __metadata: languageName: node linkType: hard +"buffer-hexdump@npm:^1.0.0": + version: 1.0.0 + resolution: "buffer-hexdump@npm:1.0.0" + checksum: cd08840fe9c52cfe7d62c1ed1a075083b0a0d42ed9cf2b030e8ca0a579bc68549e46088e5ecbb0670a7f7b9e14a859a7d38906716fc2ccae7fb77195c993753a + languageName: node + linkType: hard + "buffer-layout@npm:^1.2.0, buffer-layout@npm:^1.2.2": version: 1.2.2 resolution: "buffer-layout@npm:1.2.2" @@ -2888,6 +3025,13 @@ __metadata: languageName: node linkType: hard +"component-emitter@npm:~1.3.0": + version: 1.3.0 + resolution: "component-emitter@npm:1.3.0" + checksum: b3c46de38ffd35c57d1c02488355be9f218e582aec72d72d1b8bbec95a3ac1b38c96cd6e03ff015577e68f550fbb361a3bfdbd9bb248be9390b7b3745691be6b + languageName: node + linkType: hard + "concat-map@npm:0.0.1": version: 0.0.1 resolution: "concat-map@npm:0.0.1" @@ -3026,6 +3170,13 @@ __metadata: languageName: node linkType: hard +"cookie@npm:~0.4.1": + version: 0.4.2 + resolution: "cookie@npm:0.4.2" + checksum: a00833c998bedf8e787b4c342defe5fa419abd96b32f4464f718b91022586b8f1bafbddd499288e75c037642493c83083da426c6a9080d309e3bd90fd11baa9b + languageName: node + linkType: hard + "core-util-is@npm:1.0.2": version: 1.0.2 resolution: "core-util-is@npm:1.0.2" @@ -3040,6 +3191,16 @@ __metadata: languageName: node linkType: hard +"cors@npm:~2.8.5": + version: 2.8.5 + resolution: "cors@npm:2.8.5" + dependencies: + object-assign: ^4 + vary: ^1 + checksum: ced838404ccd184f61ab4fdc5847035b681c90db7ac17e428f3d81d69e2989d2b680cc254da0e2554f5ed4f8a341820a1ce3d1c16b499f6e2f47a1b9b07b5006 + languageName: node + linkType: hard + "cosmiconfig@npm:^7.0.0": version: 7.0.1 resolution: "cosmiconfig@npm:7.0.1" @@ -3110,6 +3271,13 @@ __metadata: languageName: node linkType: hard +"date-fns@npm:^2.28.0": + version: 2.29.1 + resolution: "date-fns@npm:2.29.1" + checksum: 9d07f77dffc1eb8c213391bde39f2963ffe7c0019d9edde14487882d627224f3a39b963e6e99d0cc58afff220a6a1a7e8864d2789958f4eaa77714de94d4d076 + languageName: node + linkType: hard + "dateformat@npm:^3.0.0": version: 3.0.3 resolution: "dateformat@npm:3.0.3" @@ -3117,7 +3285,7 @@ __metadata: languageName: node linkType: hard -"debug@npm:4, debug@npm:^4.1.0, debug@npm:^4.1.1, debug@npm:^4.3.2, debug@npm:^4.3.3, debug@npm:^4.3.4": +"debug@npm:4, debug@npm:^4.1.0, debug@npm:^4.1.1, debug@npm:^4.3.2, debug@npm:^4.3.3, debug@npm:^4.3.4, debug@npm:~4.3.1, debug@npm:~4.3.2": version: 4.3.4 resolution: "debug@npm:4.3.4" dependencies: @@ -3179,6 +3347,13 @@ __metadata: languageName: node linkType: hard +"deep-diff@npm:^1.0.2": + version: 1.0.2 + resolution: "deep-diff@npm:1.0.2" + checksum: 9de8b5eedc1957116e1b47e4c3c4e3dbe23cb741abefc5ec8829a12e77958c689ac46888a3c35320f976cf42fb6de2b016e158facdb24d894ab5b5fdabad9b34 + languageName: node + linkType: hard + "deep-equal@npm:^2.0.5": version: 2.0.5 resolution: "deep-equal@npm:2.0.5" @@ -3294,6 +3469,13 @@ __metadata: languageName: node linkType: hard +"diff@npm:^5.1.0": + version: 5.1.0 + resolution: "diff@npm:5.1.0" + checksum: c7bf0df7c9bfbe1cf8a678fd1b2137c4fb11be117a67bc18a0e03ae75105e8533dbfb1cda6b46beb3586ef5aed22143ef9d70713977d5fb1f9114e21455fba90 + languageName: node + linkType: hard + "dir-glob@npm:^3.0.1": version: 3.0.1 resolution: "dir-glob@npm:3.0.1" @@ -3406,6 +3588,44 @@ __metadata: languageName: node linkType: hard +"engine.io-client@npm:~6.2.1": + version: 6.2.2 + resolution: "engine.io-client@npm:6.2.2" + dependencies: + "@socket.io/component-emitter": ~3.1.0 + debug: ~4.3.1 + engine.io-parser: ~5.0.3 + ws: ~8.2.3 + xmlhttprequest-ssl: ~2.0.0 + checksum: bda989d88d663cda5f1fbe6b235dba35b80ba9e947685b94b40d3daf4545ccdcb54232d2ad210bbe9b5e0b73b0e019b54716d1285ed300e1f1c7ad97fd6cafaf + languageName: node + linkType: hard + +"engine.io-parser@npm:~5.0.3": + version: 5.0.4 + resolution: "engine.io-parser@npm:5.0.4" + checksum: d4ad0cef6ff63c350e35696da9bb3dbd180f67b56e93e90375010cc40393e6c0639b780d5680807e1d93a7e2e3d7b4a1c3b27cf75db28eb8cbf605bc1497da03 + languageName: node + linkType: hard + +"engine.io@npm:~6.2.0": + version: 6.2.0 + resolution: "engine.io@npm:6.2.0" + dependencies: + "@types/cookie": ^0.4.1 + "@types/cors": ^2.8.12 + "@types/node": ">=10.0.0" + accepts: ~1.3.4 + base64id: 2.0.0 + cookie: ~0.4.1 + cors: ~2.8.5 + debug: ~4.3.1 + engine.io-parser: ~5.0.3 + ws: ~8.2.3 + checksum: cc485c5ba2e0c4f6ca02dcafd192b22f9dad89d01dc815005298780d3fb910db4cebab4696e8615290c473c2eeb259e8bee2a1fb7ab594d9c80f9f3485771911 + languageName: node + linkType: hard + "env-paths@npm:^2.2.0": version: 2.2.1 resolution: "env-paths@npm:2.2.1" @@ -5760,7 +5980,7 @@ __metadata: languageName: node linkType: hard -"mime-types@npm:^2.1.12, mime-types@npm:~2.1.19": +"mime-types@npm:^2.1.12, mime-types@npm:~2.1.19, mime-types@npm:~2.1.34": version: 2.1.35 resolution: "mime-types@npm:2.1.35" dependencies: @@ -6026,7 +6246,7 @@ __metadata: languageName: node linkType: hard -"negotiator@npm:^0.6.2, negotiator@npm:^0.6.3": +"negotiator@npm:0.6.3, negotiator@npm:^0.6.2, negotiator@npm:^0.6.3": version: 0.6.3 resolution: "negotiator@npm:0.6.3" checksum: b8ffeb1e262eff7968fc90a2b6767b04cfd9842582a9d0ece0af7049537266e7b2506dfb1d107a32f06dd849ab2aea834d5830f7f4d0e5cb7d36e1ae55d021d9 @@ -6040,6 +6260,13 @@ __metadata: languageName: node linkType: hard +"netstats@npm:0.0.6": + version: 0.0.6 + resolution: "netstats@npm:0.0.6" + checksum: aceac4a6b193120185229db11afa730bc34a8b83744090c7379c9d06dcf077e132322c4084a912e89538332f4109e4acc44348017bbc34f49cbc4c29454fa069 + languageName: node + linkType: hard + "no-case@npm:^3.0.4": version: 3.0.4 resolution: "no-case@npm:3.0.4" @@ -6354,6 +6581,13 @@ __metadata: languageName: node linkType: hard +"numeral@npm:^2.0.6": + version: 2.0.6 + resolution: "numeral@npm:2.0.6" + checksum: 89f011116539692bf53fde380adeb0579623d00f782703c71c0062d4a8686770c404a041ff4eef454de53925a9f75bba1fa52726057b13d40473f707730b07c2 + languageName: node + linkType: hard + "oauth-sign@npm:~0.9.0": version: 0.9.0 resolution: "oauth-sign@npm:0.9.0" @@ -6361,7 +6595,7 @@ __metadata: languageName: node linkType: hard -"object-assign@npm:^4.1.0": +"object-assign@npm:^4, object-assign@npm:^4.1.0": version: 4.1.1 resolution: "object-assign@npm:4.1.1" checksum: fcc6e4ea8c7fe48abfbb552578b1c53e0d194086e2e6bbbf59e0a536381a292f39943c6e9628af05b5528aa5e3318bb30d6b2e53cadaf5b8fe9e12c4b69af23f @@ -6789,6 +7023,16 @@ __metadata: languageName: node linkType: hard +"port-pid@npm:^0.0.7": + version: 0.0.7 + resolution: "port-pid@npm:0.0.7" + dependencies: + netstats: 0.0.6 + selective-whitespace: ^1.0.0 + checksum: 001af20b0b66726135398a93b1a501aaec8e25171adb33fde4c994e944b2d3b68e9b189558273a494bb0b86b8438b50cecaa81d2118ac4857b7efe36bff5da72 + languageName: node + linkType: hard + "prelude-ls@npm:^1.2.1": version: 1.2.1 resolution: "prelude-ls@npm:1.2.1" @@ -7394,6 +7638,15 @@ __metadata: languageName: node linkType: hard +"selective-whitespace@npm:^1.0.0": + version: 1.0.4 + resolution: "selective-whitespace@npm:1.0.4" + dependencies: + tokenize-whitespace: 0.0.1 + checksum: ebe9a06374682a6fb5baea09c592a85bf291dd73482e6733d4b6d59836b7b3f2f4113157abd1537286e27ce47c6bb23bc740a5353b4987efba4babff1ad9d872 + languageName: node + linkType: hard + "semver@npm:2 || 3 || 4 || 5, semver@npm:^5.6.0, semver@npm:^5.7.1": version: 5.7.1 resolution: "semver@npm:5.7.1" @@ -7515,6 +7768,60 @@ __metadata: languageName: node linkType: hard +"socket.io-adapter@npm:~2.4.0": + version: 2.4.0 + resolution: "socket.io-adapter@npm:2.4.0" + checksum: a84639946dce13547b95f6e09fe167cdcd5d80941afc2e46790cc23384e0fd3c901e690ecc9bdd600939ce6292261ee15094a0b486f797ed621cfc8783d87a0c + languageName: node + linkType: hard + +"socket.io-client@npm:^4.4.1": + version: 4.5.1 + resolution: "socket.io-client@npm:4.5.1" + dependencies: + "@socket.io/component-emitter": ~3.1.0 + debug: ~4.3.2 + engine.io-client: ~6.2.1 + socket.io-parser: ~4.2.0 + checksum: e6e5ff1bb4b5714195b961274925cf23de81e070258d2ec1c8e12fcd9cebf4b4725c5fcff58699b23de8a260884f272f4e7e1e1146c0c72b75028fc438d069aa + languageName: node + linkType: hard + +"socket.io-parser@npm:~4.0.4": + version: 4.0.5 + resolution: "socket.io-parser@npm:4.0.5" + dependencies: + "@types/component-emitter": ^1.2.10 + component-emitter: ~1.3.0 + debug: ~4.3.1 + checksum: 8b60cf3abb9c3571f90cf894d40f41459ab007e6cee7ca8ee28ab107d76ded4a72ca5c4e5dcb82d996d4f78b3689dd3eb36ba0b39a66e25e2e9a9afa276c81c5 + languageName: node + linkType: hard + +"socket.io-parser@npm:~4.2.0": + version: 4.2.1 + resolution: "socket.io-parser@npm:4.2.1" + dependencies: + "@socket.io/component-emitter": ~3.1.0 + debug: ~4.3.1 + checksum: 2582202f22538d7e6b4436991378cb4cea3b2f8219cda24923ae35afd291ab5ad6120e7d093e41738256b6c6ad10c667dd25753c2d9a2340fead04e9286f152d + languageName: node + linkType: hard + +"socket.io@npm:^4.4.1": + version: 4.5.1 + resolution: "socket.io@npm:4.5.1" + dependencies: + accepts: ~1.3.4 + base64id: ~2.0.0 + debug: ~4.3.2 + engine.io: ~6.2.0 + socket.io-adapter: ~2.4.0 + socket.io-parser: ~4.0.4 + checksum: 86afd6dcce0c96de85b20a0e37fa4a21e2e96bd6e36d2518acfad37597bcb5208feafbbac20cd34ee4b9356d40418a43938bcf4a206ba693ba3c771ffcef724f + languageName: node + linkType: hard + "socks-proxy-agent@npm:^5.0.0": version: 5.0.1 resolution: "socks-proxy-agent@npm:5.0.1" @@ -7643,6 +7950,13 @@ __metadata: languageName: node linkType: hard +"split2@npm:^4.1.0": + version: 4.1.0 + resolution: "split2@npm:4.1.0" + checksum: ec581597cb74c13cdfb5e2047543dd40cb1e8e9803c7b1e0c29ede05f2b4f049b2d6e7f2788a225d544549375719658b8f38e9366364dec35dc7a12edfda5ee5 + languageName: node + linkType: hard + "split@npm:0.3": version: 0.3.3 resolution: "split@npm:0.3.3" @@ -8051,6 +8365,13 @@ __metadata: languageName: node linkType: hard +"timeago.js@npm:^4.0.2": + version: 4.0.2 + resolution: "timeago.js@npm:4.0.2" + checksum: c785a06988717cb5a00bb96b00ebaa56e83f4b5ed5d87c4c3931fb1bb2591a0e13a7ddc4b6c12c6ee7de64b440ed903c7bd4e0edddb37aade9bfc9ceab5d0db3 + languageName: node + linkType: hard + "tmp@npm:^0.0.33": version: 0.0.33 resolution: "tmp@npm:0.0.33" @@ -8069,6 +8390,13 @@ __metadata: languageName: node linkType: hard +"tokenize-whitespace@npm:0.0.1": + version: 0.0.1 + resolution: "tokenize-whitespace@npm:0.0.1" + checksum: 6dc3d02a443a1a6197576c8648ee9b93a3015ce1ef92032799052ff28d275d55278ed74aa18df8536269b93f05dcef96bd1096823cc0bf0eddf3f717b79ffc82 + languageName: node + linkType: hard + "toml@npm:^3.0.0": version: 3.0.0 resolution: "toml@npm:3.0.0" @@ -8164,7 +8492,7 @@ __metadata: languageName: node linkType: hard -"tweetnacl@npm:^1.0.0": +"tweetnacl@npm:^1.0.0, tweetnacl@npm:^1.0.3": version: 1.0.3 resolution: "tweetnacl@npm:1.0.3" checksum: e4a57cac188f0c53f24c7a33279e223618a2bfb5fea426231991652a13247bea06b081fd745d71291fcae0f4428d29beba1b984b1f1ce6f66b06a6d1ab90645c @@ -8435,6 +8763,13 @@ __metadata: languageName: node linkType: hard +"vary@npm:^1": + version: 1.1.2 + resolution: "vary@npm:1.1.2" + checksum: ae0123222c6df65b437669d63dfa8c36cee20a504101b2fcd97b8bf76f91259c17f9f2b4d70a1e3c6bbcee7f51b28392833adb6b2770b23b01abec84e369660b + languageName: node + linkType: hard + "verror@npm:1.10.0": version: 1.10.0 resolution: "verror@npm:1.10.0" @@ -8746,6 +9081,28 @@ __metadata: languageName: node linkType: hard +"ws@npm:~8.2.3": + version: 8.2.3 + resolution: "ws@npm:8.2.3" + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: ^5.0.2 + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + checksum: c869296ccb45f218ac6d32f8f614cd85b50a21fd434caf11646008eef92173be53490810c5c23aea31bc527902261fbfd7b062197eea341b26128d4be56a85e4 + languageName: node + linkType: hard + +"xmlhttprequest-ssl@npm:~2.0.0": + version: 2.0.0 + resolution: "xmlhttprequest-ssl@npm:2.0.0" + checksum: 1e98df67f004fec15754392a131343ea92e6ab5ac4d77e842378c5c4e4fd5b6a9134b169d96842cc19422d77b1606b8df84a5685562b3b698cb68441636f827e + languageName: node + linkType: hard + "xtend@npm:~4.0.1": version: 4.0.2 resolution: "xtend@npm:4.0.2" From a943b5fe18f0eff07e4e6a6a431abe2221a4311f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Flak?= Date: Tue, 9 Aug 2022 21:41:22 +0200 Subject: [PATCH 07/48] path fix --- .base-ammanrc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.base-ammanrc.js b/.base-ammanrc.js index 1e9d0cfbc0..87e2b1f8fe 100644 --- a/.base-ammanrc.js +++ b/.base-ammanrc.js @@ -43,7 +43,7 @@ const programs = { auction_house: { label: "Auction House", programId: 'hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk', - deployPath: path.join(__dirname, 'auction-house', 'program', 'target', 'deploy') + deployPath: localDeployPath('mpl_auction_house'), }, }; From 97b9a636deaa3962ee6f5b154b72614b850213d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Flak?= Date: Tue, 9 Aug 2022 22:10:32 +0200 Subject: [PATCH 08/48] Fix test --- auction-house/js/test/account.auction-house.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auction-house/js/test/account.auction-house.test.ts b/auction-house/js/test/account.auction-house.test.ts index f044c17914..d254f0ca1f 100644 --- a/auction-house/js/test/account.auction-house.test.ts +++ b/auction-house/js/test/account.auction-house.test.ts @@ -32,7 +32,7 @@ test('account auction-house: round trip serilization', async (t) => { escrowPaymentBump: 255, hasAuctioneer: false, auctioneerAddress: PublicKey.default, - scopes: [], + scopes: Array(7).fill(false), // constant size field in the contract }; const expected = AuctionHouse.fromArgs(args); From b5683448459a0192c009818fd81b7eee76c6b4b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Flak?= Date: Tue, 9 Aug 2022 22:22:10 +0200 Subject: [PATCH 09/48] amman stop --- auction-house/js/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auction-house/js/package.json b/auction-house/js/package.json index 353e854e20..3aec1009a7 100644 --- a/auction-house/js/package.json +++ b/auction-house/js/package.json @@ -15,7 +15,7 @@ "build:watch": "rimraf dist && tsc -p tsconfig.json --watch", "amman:start": "DEBUG=\"amman*\" amman start", "amman:start-custom-ammanrc": "DEBUG=\"amman*\" amman start ${0}", - "amman:stop": "pkill solana-test-validator", + "amman:stop": "DEBUG=\"amman*\" amman stop", "test:all": "yarn build && yarn amman:start && yarn test", "test:all-custom-ammanrc": "yarn build && yarn amman:start ${0} && yarn test", "test": "esr ./test/*.test.ts", From 4d0c304ab1e4de172af39ed41b61e225d526901f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Flak?= Date: Tue, 9 Aug 2022 22:53:45 +0200 Subject: [PATCH 10/48] Hopes and prayers --- .github/workflows/integration-auction-house.yml | 10 +--------- auction-house/js/.gitignore | 1 + auction-house/js/onchain.ammanrc.js | 8 ++++---- metaplex/js/package.json | 4 ++-- 4 files changed, 8 insertions(+), 15 deletions(-) create mode 100644 auction-house/js/.gitignore diff --git a/.github/workflows/integration-auction-house.yml b/.github/workflows/integration-auction-house.yml index 6cf9c02d74..65bad7a3ed 100644 --- a/.github/workflows/integration-auction-house.yml +++ b/.github/workflows/integration-auction-house.yml @@ -77,10 +77,6 @@ jobs: working-directory: ./auction-house/js run: DEBUG=mpl* yarn test - - name: stop-local-test-validator - working-directory: ./auction-house/js - run: DEBUG=amman* yarn amman:stop - # Run integration test - onchain program - name: start-local-test-validator-onchain working-directory: ./auction-house/js @@ -89,8 +85,4 @@ jobs: - name: integration-test-auction-house-program id: run_integration_test_onchain working-directory: ./auction-house/js - run: DEBUG=mpl* yarn test - - - name: stop-local-test-validator - working-directory: ./auction-house/js - run: DEBUG=amman* yarn amman:stop + run: DEBUG=mpl* yarn test \ No newline at end of file diff --git a/auction-house/js/.gitignore b/auction-house/js/.gitignore new file mode 100644 index 0000000000..6e4834ddf9 --- /dev/null +++ b/auction-house/js/.gitignore @@ -0,0 +1 @@ +.amman \ No newline at end of file diff --git a/auction-house/js/onchain.ammanrc.js b/auction-house/js/onchain.ammanrc.js index 3a887615ea..8675a4361a 100644 --- a/auction-house/js/onchain.ammanrc.js +++ b/auction-house/js/onchain.ammanrc.js @@ -2,13 +2,13 @@ // @ts-check const base = require('../../.base-ammanrc.js'); -const accounts = { - auction_house: { +const accounts = [ + { label: "Auction House", - programId: 'hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk', + accountId: 'hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk', executable: true, }, -} +] const validator = { ...base.validator, diff --git a/metaplex/js/package.json b/metaplex/js/package.json index 74531988da..d3fabd92a7 100644 --- a/metaplex/js/package.json +++ b/metaplex/js/package.json @@ -14,9 +14,9 @@ "build": "rimraf dist && tsc -p tsconfig.json", "pretest": "yarn build", "test:build": "esr ./test/setup/build.ts", - "amman:start": "DEBUG=\"amman*\" amman validator", + "amman:start": "DEBUG=\"amman*\" amman validator ${0}", "amman:stop": "pkill solana-test-validator", - "test:all": "yarn test:build && yarn amman:start && yarn test", + "test:all": "yarn test:build && yarn amman:start --config ${0} && yarn test", "test": "tape ./dist/test/*.test.js", "lint": "eslint \"{src,test}/**/*.ts\" --format stylish", "fix:lint": "yarn lint --fix", From 882355d5d35aa803250848f4ce541837d7e80b01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Flak?= Date: Tue, 9 Aug 2022 23:04:35 +0200 Subject: [PATCH 11/48] amman stop --- .github/workflows/integration-auction-house.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/integration-auction-house.yml b/.github/workflows/integration-auction-house.yml index 65bad7a3ed..6cf9c02d74 100644 --- a/.github/workflows/integration-auction-house.yml +++ b/.github/workflows/integration-auction-house.yml @@ -77,6 +77,10 @@ jobs: working-directory: ./auction-house/js run: DEBUG=mpl* yarn test + - name: stop-local-test-validator + working-directory: ./auction-house/js + run: DEBUG=amman* yarn amman:stop + # Run integration test - onchain program - name: start-local-test-validator-onchain working-directory: ./auction-house/js @@ -85,4 +89,8 @@ jobs: - name: integration-test-auction-house-program id: run_integration_test_onchain working-directory: ./auction-house/js - run: DEBUG=mpl* yarn test \ No newline at end of file + run: DEBUG=mpl* yarn test + + - name: stop-local-test-validator + working-directory: ./auction-house/js + run: DEBUG=amman* yarn amman:stop From 121ad23a201f78dd460ec97ae6dfcd464c2ac014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Flak?= Date: Tue, 9 Aug 2022 23:16:56 +0200 Subject: [PATCH 12/48] fix --- auction-house/js/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/auction-house/js/package.json b/auction-house/js/package.json index 3aec1009a7..899da4abb9 100644 --- a/auction-house/js/package.json +++ b/auction-house/js/package.json @@ -14,10 +14,10 @@ "build": "rimraf dist && tsc -p tsconfig.json", "build:watch": "rimraf dist && tsc -p tsconfig.json --watch", "amman:start": "DEBUG=\"amman*\" amman start", - "amman:start-custom-ammanrc": "DEBUG=\"amman*\" amman start ${0}", + "amman:start-custom-ammanrc": "DEBUG=\"amman*\" amman start --config ${0}", "amman:stop": "DEBUG=\"amman*\" amman stop", "test:all": "yarn build && yarn amman:start && yarn test", - "test:all-custom-ammanrc": "yarn build && yarn amman:start ${0} && yarn test", + "test:all-custom-ammanrc": "yarn build && yarn amman:start-custom-ammanrc ${0} && yarn test", "test": "esr ./test/*.test.ts", "api:gen": "DEBUG='(solita|rustbin):(info|error)' solita", "lint": "eslint \"{src,test}/**/*.ts\" --format stylish", From fd73746b7db82010ff22f7052181356e8e32aecd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Flak?= Date: Tue, 9 Aug 2022 23:18:18 +0200 Subject: [PATCH 13/48] fix metaplex --- metaplex/js/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/metaplex/js/package.json b/metaplex/js/package.json index d3fabd92a7..74531988da 100644 --- a/metaplex/js/package.json +++ b/metaplex/js/package.json @@ -14,9 +14,9 @@ "build": "rimraf dist && tsc -p tsconfig.json", "pretest": "yarn build", "test:build": "esr ./test/setup/build.ts", - "amman:start": "DEBUG=\"amman*\" amman validator ${0}", + "amman:start": "DEBUG=\"amman*\" amman validator", "amman:stop": "pkill solana-test-validator", - "test:all": "yarn test:build && yarn amman:start --config ${0} && yarn test", + "test:all": "yarn test:build && yarn amman:start && yarn test", "test": "tape ./dist/test/*.test.js", "lint": "eslint \"{src,test}/**/*.ts\" --format stylish", "fix:lint": "yarn lint --fix", From a737e16e68d185b6ecc5ae60dd2c39ce84659915 Mon Sep 17 00:00:00 2001 From: jdcaballerov Date: Tue, 9 Aug 2022 16:51:33 -0500 Subject: [PATCH 14/48] Test anchor --- auction-house/js/test/account.auction-house.test.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/auction-house/js/test/account.auction-house.test.ts b/auction-house/js/test/account.auction-house.test.ts index d254f0ca1f..6f1cc45265 100644 --- a/auction-house/js/test/account.auction-house.test.ts +++ b/auction-house/js/test/account.auction-house.test.ts @@ -1,5 +1,7 @@ import { AccountInfo, Keypair, PublicKey } from '@solana/web3.js'; import { AuctionHouse, AuctionHouseArgs } from 'src/generated'; +import * as anchor from '@project-serum/anchor'; +// import { Program } from '@project-serum/anchor'; import test from 'tape'; import spok from 'spok'; @@ -48,3 +50,9 @@ test('account auction-house: round trip serilization', async (t) => { const actual = AuctionHouse.fromAccountInfo(info)[0]; spok(t, actual, expected); }); + +test('account auction-house: round trip serilization', async (t) => { + const provider = anchor.Provider.env(); + anchor.setProvider(provider); + t.ok(true); +}); From 1b66e15c85b7242d4abb752fb2540d6bbd4d1d77 Mon Sep 17 00:00:00 2001 From: jdcaballerov Date: Tue, 9 Aug 2022 17:30:08 -0500 Subject: [PATCH 15/48] Test aidrop --- .../js/test/account.auction-house.test.ts | 36 +++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/auction-house/js/test/account.auction-house.test.ts b/auction-house/js/test/account.auction-house.test.ts index 6f1cc45265..c1573f2e75 100644 --- a/auction-house/js/test/account.auction-house.test.ts +++ b/auction-house/js/test/account.auction-house.test.ts @@ -1,9 +1,20 @@ -import { AccountInfo, Keypair, PublicKey } from '@solana/web3.js'; -import { AuctionHouse, AuctionHouseArgs } from 'src/generated'; -import * as anchor from '@project-serum/anchor'; -// import { Program } from '@project-serum/anchor'; +import { AccountInfo, Connection, Keypair, PublicKey } from '@solana/web3.js'; +import { + AuctionHouse, + AuctionHouseArgs, + // CreateAuctionHouseInstructionAccounts, + // CreateAuctionHouseInstructionArgs, + // createCreateAuctionHouseInstruction, +} from 'src/generated'; import test from 'tape'; import spok from 'spok'; +import { Amman } from '@metaplex-foundation/amman-client'; + +const connectionURL = 'http://localhost:8899'; +export const amman = Amman.instance({ + knownLabels: { ['hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk']: 'Auction House' }, + log: console.log, +}); function quickKeypair(): [PublicKey, Uint8Array] { const kp = Keypair.generate(); @@ -51,8 +62,19 @@ test('account auction-house: round trip serilization', async (t) => { spok(t, actual, expected); }); -test('account auction-house: round trip serilization', async (t) => { - const provider = anchor.Provider.env(); - anchor.setProvider(provider); +test('instruction auction-house: create auction-house', async (t) => { + const authority = quickKeypair(); + const connection = new Connection(connectionURL, 'confirmed'); + await amman.airdrop(connection, authority[0], 2); + // const accounts: CreateAuctionHouseInstructionAccounts = { + // treasuryMint: web3.PublicKey, + // payer: web3.PublicKey, + // authority: web3.PublicKey, + // feeWithdrawalDestination: web3.PublicKey, + // treasuryWithdrawalDestination: web3.PublicKey, + // treasuryWithdrawalDestinationOwner: web3.PublicKey, auctionHouse: web3.PublicKey; + // auctionHouseFeeAccount: web3.PublicKey, + // auctionHouseTreasury: web3.PublicKey, + // }; t.ok(true); }); From 2d57f4551faba77145012bb7b7e609abc42097a7 Mon Sep 17 00:00:00 2001 From: jdcaballerov Date: Wed, 10 Aug 2022 11:00:18 -0500 Subject: [PATCH 16/48] Implement AH transaction --- .../js/test/account.auction-house.test.ts | 96 +++++++++++++++---- 1 file changed, 78 insertions(+), 18 deletions(-) diff --git a/auction-house/js/test/account.auction-house.test.ts b/auction-house/js/test/account.auction-house.test.ts index c1573f2e75..eb751c2e1d 100644 --- a/auction-house/js/test/account.auction-house.test.ts +++ b/auction-house/js/test/account.auction-house.test.ts @@ -1,15 +1,23 @@ -import { AccountInfo, Connection, Keypair, PublicKey } from '@solana/web3.js'; +import { AccountInfo, Connection, Keypair, PublicKey, Transaction } from '@solana/web3.js'; import { AuctionHouse, AuctionHouseArgs, - // CreateAuctionHouseInstructionAccounts, - // CreateAuctionHouseInstructionArgs, - // createCreateAuctionHouseInstruction, + CreateAuctionHouseInstructionAccounts, + CreateAuctionHouseInstructionArgs, + createCreateAuctionHouseInstruction, } from 'src/generated'; import test from 'tape'; import spok from 'spok'; import { Amman } from '@metaplex-foundation/amman-client'; +const WRAPPED_SOL_MINT = new PublicKey('So11111111111111111111111111111111111111112'); +export const AUCTION_HOUSE = 'auction_house'; +export const FEE_PAYER = 'fee_payer'; +export const TREASURY = 'treasury'; + +export const AUCTION_HOUSE_PROGRAM_ID = new PublicKey( + 'hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk', +); const connectionURL = 'http://localhost:8899'; export const amman = Amman.instance({ knownLabels: { ['hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk']: 'Auction House' }, @@ -21,7 +29,35 @@ function quickKeypair(): [PublicKey, Uint8Array] { return [kp.publicKey, kp.secretKey]; } -test('account auction-house: round trip serilization', async (t) => { +export const getAuctionHouse = async ( + creator: PublicKey, + treasuryMint: PublicKey, +): Promise<[PublicKey, number]> => { + return await PublicKey.findProgramAddress( + [Buffer.from(AUCTION_HOUSE), creator.toBuffer(), treasuryMint.toBuffer()], + AUCTION_HOUSE_PROGRAM_ID, + ); +}; + +export const getAuctionHouseFeeAcct = async ( + auctionHouse: PublicKey, +): Promise<[PublicKey, number]> => { + return await PublicKey.findProgramAddress( + [Buffer.from(AUCTION_HOUSE), auctionHouse.toBuffer(), Buffer.from(FEE_PAYER)], + AUCTION_HOUSE_PROGRAM_ID, + ); +}; + +export const getAuctionHouseTreasuryAcct = async ( + auctionHouse: PublicKey, +): Promise<[PublicKey, number]> => { + return await PublicKey.findProgramAddress( + [Buffer.from(AUCTION_HOUSE), auctionHouse.toBuffer(), Buffer.from(TREASURY)], + AUCTION_HOUSE_PROGRAM_ID, + ); +}; + +test('account auction-house: round trip serialization', async (t) => { const [creator] = quickKeypair(); const [auctionHouseTreasury] = quickKeypair(); const [treasuryWithdrawalDestination] = quickKeypair(); @@ -63,18 +99,42 @@ test('account auction-house: round trip serilization', async (t) => { }); test('instruction auction-house: create auction-house', async (t) => { - const authority = quickKeypair(); + const authority = Keypair.generate(); + const treasuryWithdrawal = Keypair.generate(); const connection = new Connection(connectionURL, 'confirmed'); - await amman.airdrop(connection, authority[0], 2); - // const accounts: CreateAuctionHouseInstructionAccounts = { - // treasuryMint: web3.PublicKey, - // payer: web3.PublicKey, - // authority: web3.PublicKey, - // feeWithdrawalDestination: web3.PublicKey, - // treasuryWithdrawalDestination: web3.PublicKey, - // treasuryWithdrawalDestinationOwner: web3.PublicKey, auctionHouse: web3.PublicKey; - // auctionHouseFeeAccount: web3.PublicKey, - // auctionHouseTreasury: web3.PublicKey, - // }; - t.ok(true); + const transactionHandler = amman.payerTransactionHandler(connection, authority); + await amman.airdrop(connection, authority.publicKey, 2); + + const [auctionHouse, ahBump] = await getAuctionHouse(authority.publicKey, WRAPPED_SOL_MINT); + const [feeAccount, feeBump] = await getAuctionHouseFeeAcct(auctionHouse); + const [treasuryAccount, treasuryBump] = await getAuctionHouseTreasuryAcct(auctionHouse); + + const accounts: CreateAuctionHouseInstructionAccounts = { + treasuryMint: WRAPPED_SOL_MINT, + payer: authority.publicKey, + authority: authority.publicKey, + feeWithdrawalDestination: authority.publicKey, + treasuryWithdrawalDestination: treasuryWithdrawal.publicKey, + treasuryWithdrawalDestinationOwner: treasuryWithdrawal.publicKey, + auctionHouse: auctionHouse, + auctionHouseFeeAccount: feeAccount, + auctionHouseTreasury: treasuryAccount, + }; + + const args: CreateAuctionHouseInstructionArgs = { + bump: ahBump, + feePayerBump: feeBump, + treasuryBump: treasuryBump, + sellerFeeBasisPoints: 250, + requiresSignOff: false, + canChangeSalePrice: false, + }; + const create_ah_instruction = createCreateAuctionHouseInstruction(accounts, args); + const tx = new Transaction().add(create_ah_instruction); + tx.recentBlockhash = (await connection.getRecentBlockhash()).blockhash; + const txId = await transactionHandler.sendAndConfirmTransaction(tx, [authority], { + skipPreflight: true, + }); + + t.ok(txId); }); From 143bac782c75994a1b03f480dfd50b3f5ef15551 Mon Sep 17 00:00:00 2001 From: jdcaballerov Date: Wed, 10 Aug 2022 11:10:14 -0500 Subject: [PATCH 17/48] Dont skip preflight --- auction-house/js/test/account.auction-house.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auction-house/js/test/account.auction-house.test.ts b/auction-house/js/test/account.auction-house.test.ts index eb751c2e1d..ab565fdacd 100644 --- a/auction-house/js/test/account.auction-house.test.ts +++ b/auction-house/js/test/account.auction-house.test.ts @@ -133,7 +133,7 @@ test('instruction auction-house: create auction-house', async (t) => { const tx = new Transaction().add(create_ah_instruction); tx.recentBlockhash = (await connection.getRecentBlockhash()).blockhash; const txId = await transactionHandler.sendAndConfirmTransaction(tx, [authority], { - skipPreflight: true, + // skipPreflight: true, }); t.ok(txId); From 56f26620f52d995d252e1102ff90f4f532efeed0 Mon Sep 17 00:00:00 2001 From: jdcaballerov Date: Wed, 10 Aug 2022 11:11:15 -0500 Subject: [PATCH 18/48] skip preflight set to false --- auction-house/js/test/account.auction-house.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auction-house/js/test/account.auction-house.test.ts b/auction-house/js/test/account.auction-house.test.ts index ab565fdacd..fcae62f837 100644 --- a/auction-house/js/test/account.auction-house.test.ts +++ b/auction-house/js/test/account.auction-house.test.ts @@ -133,7 +133,7 @@ test('instruction auction-house: create auction-house', async (t) => { const tx = new Transaction().add(create_ah_instruction); tx.recentBlockhash = (await connection.getRecentBlockhash()).blockhash; const txId = await transactionHandler.sendAndConfirmTransaction(tx, [authority], { - // skipPreflight: true, + skipPreflight: false, }); t.ok(txId); From e7c63b918e578e28f69a478ddc0a45bb67385c10 Mon Sep 17 00:00:00 2001 From: jdcaballerov Date: Wed, 10 Aug 2022 11:43:05 -0500 Subject: [PATCH 19/48] Nest test --- .../js/test/account.auction-house.test.ts | 79 ++++++++++--------- 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/auction-house/js/test/account.auction-house.test.ts b/auction-house/js/test/account.auction-house.test.ts index fcae62f837..9914027b8c 100644 --- a/auction-house/js/test/account.auction-house.test.ts +++ b/auction-house/js/test/account.auction-house.test.ts @@ -98,43 +98,46 @@ test('account auction-house: round trip serialization', async (t) => { spok(t, actual, expected); }); -test('instruction auction-house: create auction-house', async (t) => { - const authority = Keypair.generate(); - const treasuryWithdrawal = Keypair.generate(); - const connection = new Connection(connectionURL, 'confirmed'); - const transactionHandler = amman.payerTransactionHandler(connection, authority); - await amman.airdrop(connection, authority.publicKey, 2); - - const [auctionHouse, ahBump] = await getAuctionHouse(authority.publicKey, WRAPPED_SOL_MINT); - const [feeAccount, feeBump] = await getAuctionHouseFeeAcct(auctionHouse); - const [treasuryAccount, treasuryBump] = await getAuctionHouseTreasuryAcct(auctionHouse); - - const accounts: CreateAuctionHouseInstructionAccounts = { - treasuryMint: WRAPPED_SOL_MINT, - payer: authority.publicKey, - authority: authority.publicKey, - feeWithdrawalDestination: authority.publicKey, - treasuryWithdrawalDestination: treasuryWithdrawal.publicKey, - treasuryWithdrawalDestinationOwner: treasuryWithdrawal.publicKey, - auctionHouse: auctionHouse, - auctionHouseFeeAccount: feeAccount, - auctionHouseTreasury: treasuryAccount, - }; - - const args: CreateAuctionHouseInstructionArgs = { - bump: ahBump, - feePayerBump: feeBump, - treasuryBump: treasuryBump, - sellerFeeBasisPoints: 250, - requiresSignOff: false, - canChangeSalePrice: false, - }; - const create_ah_instruction = createCreateAuctionHouseInstruction(accounts, args); - const tx = new Transaction().add(create_ah_instruction); - tx.recentBlockhash = (await connection.getRecentBlockhash()).blockhash; - const txId = await transactionHandler.sendAndConfirmTransaction(tx, [authority], { - skipPreflight: false, +test('test auction-house instructions', async (t) => { + test('instruction auction-house: create auction-house', async (t) => { + const authority = Keypair.generate(); + const treasuryWithdrawal = Keypair.generate(); + const connection = new Connection(connectionURL, 'confirmed'); + const transactionHandler = amman.payerTransactionHandler(connection, authority); + await amman.airdrop(connection, authority.publicKey, 2); + + const [auctionHouse, ahBump] = await getAuctionHouse(authority.publicKey, WRAPPED_SOL_MINT); + const [feeAccount, feeBump] = await getAuctionHouseFeeAcct(auctionHouse); + const [treasuryAccount, treasuryBump] = await getAuctionHouseTreasuryAcct(auctionHouse); + + const accounts: CreateAuctionHouseInstructionAccounts = { + treasuryMint: WRAPPED_SOL_MINT, + payer: authority.publicKey, + authority: authority.publicKey, + feeWithdrawalDestination: authority.publicKey, + treasuryWithdrawalDestination: treasuryWithdrawal.publicKey, + treasuryWithdrawalDestinationOwner: treasuryWithdrawal.publicKey, + auctionHouse: auctionHouse, + auctionHouseFeeAccount: feeAccount, + auctionHouseTreasury: treasuryAccount, + }; + + const args: CreateAuctionHouseInstructionArgs = { + bump: ahBump, + feePayerBump: feeBump, + treasuryBump: treasuryBump, + sellerFeeBasisPoints: 250, + requiresSignOff: false, + canChangeSalePrice: false, + }; + const create_ah_instruction = createCreateAuctionHouseInstruction(accounts, args); + const tx = new Transaction().add(create_ah_instruction); + tx.recentBlockhash = (await connection.getRecentBlockhash()).blockhash; + const txId = await transactionHandler.sendAndConfirmTransaction(tx, [authority], { + skipPreflight: false, + }); + + t.ok(txId); }); - - t.ok(txId); + t.ok(true); }); From df4e755eb74a061caea90e0f34032a57c153f22e Mon Sep 17 00:00:00 2001 From: jdcaballerov Date: Wed, 10 Aug 2022 12:06:15 -0500 Subject: [PATCH 20/48] Add deposit test --- .../js/test/account.auction-house.test.ts | 54 ++++++++++++++++++- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/auction-house/js/test/account.auction-house.test.ts b/auction-house/js/test/account.auction-house.test.ts index 9914027b8c..dad06af84d 100644 --- a/auction-house/js/test/account.auction-house.test.ts +++ b/auction-house/js/test/account.auction-house.test.ts @@ -5,6 +5,10 @@ import { CreateAuctionHouseInstructionAccounts, CreateAuctionHouseInstructionArgs, createCreateAuctionHouseInstruction, + DepositInstructionAccounts, + DepositInstructionArgs, + createDepositInstruction, + // createAuctioneerWithdrawInstruction, } from 'src/generated'; import test from 'tape'; import spok from 'spok'; @@ -57,6 +61,16 @@ export const getAuctionHouseTreasuryAcct = async ( ); }; +export const getAuctionHouseBuyerEscrow = async ( + auctionHouse: PublicKey, + wallet: PublicKey, +): Promise<[PublicKey, number]> => { + return await PublicKey.findProgramAddress( + [Buffer.from(AUCTION_HOUSE), auctionHouse.toBuffer(), wallet.toBuffer()], + AUCTION_HOUSE_PROGRAM_ID, + ); +}; + test('account auction-house: round trip serialization', async (t) => { const [creator] = quickKeypair(); const [auctionHouseTreasury] = quickKeypair(); @@ -99,10 +113,11 @@ test('account auction-house: round trip serialization', async (t) => { }); test('test auction-house instructions', async (t) => { + const authority = Keypair.generate(); + const connection = new Connection(connectionURL, 'confirmed'); + test('instruction auction-house: create auction-house', async (t) => { - const authority = Keypair.generate(); const treasuryWithdrawal = Keypair.generate(); - const connection = new Connection(connectionURL, 'confirmed'); const transactionHandler = amman.payerTransactionHandler(connection, authority); await amman.airdrop(connection, authority.publicKey, 2); @@ -136,6 +151,41 @@ test('test auction-house instructions', async (t) => { const txId = await transactionHandler.sendAndConfirmTransaction(tx, [authority], { skipPreflight: false, }); + t.ok(txId); + }); + test('instruction auction-house: deposit and withdraw', async (t) => { + const wallet = Keypair.generate(); + const transactionHandler = amman.payerTransactionHandler(connection, wallet); + const [auctionHouse, {}] = await getAuctionHouse(authority.publicKey, WRAPPED_SOL_MINT); + const [feeAccount, {}] = await getAuctionHouseFeeAcct(auctionHouse); + const [escrowPaymentAccount, escrowPaymentBump] = await getAuctionHouseBuyerEscrow( + auctionHouse, + wallet.publicKey, + ); + + await amman.airdrop(connection, wallet.publicKey, 2); + const depositAccounts: DepositInstructionAccounts = { + wallet: wallet.publicKey, + paymentAccount: wallet.publicKey, + transferAuthority: authority.publicKey, + escrowPaymentAccount: escrowPaymentAccount, + treasuryMint: WRAPPED_SOL_MINT, + authority: authority.publicKey, + auctionHouse: auctionHouse, + auctionHouseFeeAccount: feeAccount, + }; + + const args: DepositInstructionArgs = { + escrowPaymentBump: escrowPaymentBump, + amount: 1000, + }; + + const deposit_instruction = createDepositInstruction(depositAccounts, args); + const tx = new Transaction().add(deposit_instruction); + tx.recentBlockhash = (await connection.getRecentBlockhash()).blockhash; + const txId = await transactionHandler.sendAndConfirmTransaction(tx, [wallet], { + skipPreflight: false, + }); t.ok(txId); }); From 09b408b2a03102f817bf72b0544c0621f739e3fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Flak?= Date: Wed, 10 Aug 2022 20:35:33 +0200 Subject: [PATCH 21/48] Assert wallet_sol_post_balance post deposit --- .../js/test/account.auction-house.test.ts | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/auction-house/js/test/account.auction-house.test.ts b/auction-house/js/test/account.auction-house.test.ts index dad06af84d..d84e46a579 100644 --- a/auction-house/js/test/account.auction-house.test.ts +++ b/auction-house/js/test/account.auction-house.test.ts @@ -1,4 +1,4 @@ -import { AccountInfo, Connection, Keypair, PublicKey, Transaction } from '@solana/web3.js'; +import { AccountInfo, Connection, Keypair, PublicKey, Transaction, LAMPORTS_PER_SOL} from '@solana/web3.js'; import { AuctionHouse, AuctionHouseArgs, @@ -18,6 +18,7 @@ const WRAPPED_SOL_MINT = new PublicKey('So11111111111111111111111111111111111111 export const AUCTION_HOUSE = 'auction_house'; export const FEE_PAYER = 'fee_payer'; export const TREASURY = 'treasury'; +const REQUIRED_RENT_EXEMPTION = 890_880 export const AUCTION_HOUSE_PROGRAM_ID = new PublicKey( 'hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk', @@ -119,7 +120,13 @@ test('test auction-house instructions', async (t) => { test('instruction auction-house: create auction-house', async (t) => { const treasuryWithdrawal = Keypair.generate(); const transactionHandler = amman.payerTransactionHandler(connection, authority); - await amman.airdrop(connection, authority.publicKey, 2); + const authority_aidrop_sol = 2 + + test('airdrop to AH authority', async(t) => { + await amman.airdrop(connection, authority.publicKey, authority_aidrop_sol); + const authority_balance = await connection.getBalance(authority.publicKey); + t.equal(authority_balance/LAMPORTS_PER_SOL, authority_aidrop_sol); + }); const [auctionHouse, ahBump] = await getAuctionHouse(authority.publicKey, WRAPPED_SOL_MINT); const [feeAccount, feeBump] = await getAuctionHouseFeeAcct(auctionHouse); @@ -163,7 +170,11 @@ test('test auction-house instructions', async (t) => { wallet.publicKey, ); + const auction_house_fee_account_pre_balance = await connection.getBalance(feeAccount); await amman.airdrop(connection, wallet.publicKey, 2); + const wallet_sol_pre_balance = await connection.getBalance(wallet.publicKey); + const deposit_amount = 1000; + const depositAccounts: DepositInstructionAccounts = { wallet: wallet.publicKey, paymentAccount: wallet.publicKey, @@ -177,7 +188,7 @@ test('test auction-house instructions', async (t) => { const args: DepositInstructionArgs = { escrowPaymentBump: escrowPaymentBump, - amount: 1000, + amount: deposit_amount, }; const deposit_instruction = createDepositInstruction(depositAccounts, args); @@ -187,7 +198,10 @@ test('test auction-house instructions', async (t) => { skipPreflight: false, }); - t.ok(txId); + const deposit_fee_paid = (await connection.getFeeForMessage(tx.compileMessage())).value; + const wallet_sol_post_balance = await connection.getBalance(wallet.publicKey); + + t.equal(wallet_sol_post_balance, wallet_sol_pre_balance - deposit_amount - deposit_fee_paid - REQUIRED_RENT_EXEMPTION) }); t.ok(true); }); From 6e2693c3a2ec0dc30f855cc387b45b17c8c52341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Flak?= Date: Wed, 10 Aug 2022 20:50:49 +0200 Subject: [PATCH 22/48] tslint --- auction-house/js/test/account.auction-house.test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/auction-house/js/test/account.auction-house.test.ts b/auction-house/js/test/account.auction-house.test.ts index d84e46a579..d40d51c09d 100644 --- a/auction-house/js/test/account.auction-house.test.ts +++ b/auction-house/js/test/account.auction-house.test.ts @@ -170,6 +170,7 @@ test('test auction-house instructions', async (t) => { wallet.publicKey, ); + /* tslint:disable:no-unused-variable */ const auction_house_fee_account_pre_balance = await connection.getBalance(feeAccount); await amman.airdrop(connection, wallet.publicKey, 2); const wallet_sol_pre_balance = await connection.getBalance(wallet.publicKey); @@ -194,6 +195,7 @@ test('test auction-house instructions', async (t) => { const deposit_instruction = createDepositInstruction(depositAccounts, args); const tx = new Transaction().add(deposit_instruction); tx.recentBlockhash = (await connection.getRecentBlockhash()).blockhash; + /* tslint:disable:no-unused-variable */ const txId = await transactionHandler.sendAndConfirmTransaction(tx, [wallet], { skipPreflight: false, }); From f008b51e5d4d6288815351c8783f53868e6ead61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Flak?= Date: Wed, 10 Aug 2022 20:59:03 +0200 Subject: [PATCH 23/48] grrr tslint --- auction-house/js/test/account.auction-house.test.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/auction-house/js/test/account.auction-house.test.ts b/auction-house/js/test/account.auction-house.test.ts index d40d51c09d..e7aea60011 100644 --- a/auction-house/js/test/account.auction-house.test.ts +++ b/auction-house/js/test/account.auction-house.test.ts @@ -170,8 +170,7 @@ test('test auction-house instructions', async (t) => { wallet.publicKey, ); - /* tslint:disable:no-unused-variable */ - const auction_house_fee_account_pre_balance = await connection.getBalance(feeAccount); + //const auction_house_fee_account_pre_balance = await connection.getBalance(feeAccount); await amman.airdrop(connection, wallet.publicKey, 2); const wallet_sol_pre_balance = await connection.getBalance(wallet.publicKey); const deposit_amount = 1000; @@ -195,8 +194,7 @@ test('test auction-house instructions', async (t) => { const deposit_instruction = createDepositInstruction(depositAccounts, args); const tx = new Transaction().add(deposit_instruction); tx.recentBlockhash = (await connection.getRecentBlockhash()).blockhash; - /* tslint:disable:no-unused-variable */ - const txId = await transactionHandler.sendAndConfirmTransaction(tx, [wallet], { + /*const txId = */ await transactionHandler.sendAndConfirmTransaction(tx, [wallet], { skipPreflight: false, }); From 96458a8c6b4a5e73cf5a17248da77b0a6d1a5eae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Flak?= Date: Wed, 10 Aug 2022 21:12:47 +0200 Subject: [PATCH 24/48] airdrop fix --- auction-house/js/test/account.auction-house.test.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/auction-house/js/test/account.auction-house.test.ts b/auction-house/js/test/account.auction-house.test.ts index e7aea60011..f1fbeb79da 100644 --- a/auction-house/js/test/account.auction-house.test.ts +++ b/auction-house/js/test/account.auction-house.test.ts @@ -121,12 +121,9 @@ test('test auction-house instructions', async (t) => { const treasuryWithdrawal = Keypair.generate(); const transactionHandler = amman.payerTransactionHandler(connection, authority); const authority_aidrop_sol = 2 - - test('airdrop to AH authority', async(t) => { - await amman.airdrop(connection, authority.publicKey, authority_aidrop_sol); - const authority_balance = await connection.getBalance(authority.publicKey); - t.equal(authority_balance/LAMPORTS_PER_SOL, authority_aidrop_sol); - }); + await amman.airdrop(connection, authority.publicKey, authority_aidrop_sol); + const authority_balance = await connection.getBalance(authority.publicKey); + t.equal(authority_balance/LAMPORTS_PER_SOL, authority_aidrop_sol); const [auctionHouse, ahBump] = await getAuctionHouse(authority.publicKey, WRAPPED_SOL_MINT); const [feeAccount, feeBump] = await getAuctionHouseFeeAcct(auctionHouse); @@ -159,6 +156,7 @@ test('test auction-house instructions', async (t) => { skipPreflight: false, }); t.ok(txId); + t.end(); }); test('instruction auction-house: deposit and withdraw', async (t) => { const wallet = Keypair.generate(); From 906a63148c6b4b33801f6028a1fdbd0a18401e25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Flak?= Date: Wed, 10 Aug 2022 21:26:39 +0200 Subject: [PATCH 25/48] lsol post balance --- auction-house/js/test/account.auction-house.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/auction-house/js/test/account.auction-house.test.ts b/auction-house/js/test/account.auction-house.test.ts index f1fbeb79da..9a929a485e 100644 --- a/auction-house/js/test/account.auction-house.test.ts +++ b/auction-house/js/test/account.auction-house.test.ts @@ -198,8 +198,10 @@ test('test auction-house instructions', async (t) => { const deposit_fee_paid = (await connection.getFeeForMessage(tx.compileMessage())).value; const wallet_sol_post_balance = await connection.getBalance(wallet.publicKey); + const lsol_post_balance = await connection.getBalance(escrowPaymentAccount); - t.equal(wallet_sol_post_balance, wallet_sol_pre_balance - deposit_amount - deposit_fee_paid - REQUIRED_RENT_EXEMPTION) + t.equal(wallet_sol_post_balance, wallet_sol_pre_balance - deposit_amount - deposit_fee_paid - REQUIRED_RENT_EXEMPTION, "wallet_sol_post_balance") + t.equal(lsol_post_balance, deposit_amount + REQUIRED_RENT_EXEMPTION, "escrow_sol_post_balance") }); t.ok(true); }); From 5f192cd159c9380dadf71bc4b5b08ea99383126e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Flak?= Date: Wed, 10 Aug 2022 22:35:08 +0200 Subject: [PATCH 26/48] withdraw asserts --- .../js/test/account.auction-house.test.ts | 56 ++++++++++++++++--- 1 file changed, 47 insertions(+), 9 deletions(-) diff --git a/auction-house/js/test/account.auction-house.test.ts b/auction-house/js/test/account.auction-house.test.ts index 9a929a485e..cae2cbc621 100644 --- a/auction-house/js/test/account.auction-house.test.ts +++ b/auction-house/js/test/account.auction-house.test.ts @@ -8,6 +8,9 @@ import { DepositInstructionAccounts, DepositInstructionArgs, createDepositInstruction, + WithdrawInstructionAccounts, + WithdrawInstructionArgs, + createWithdrawInstruction, // createAuctioneerWithdrawInstruction, } from 'src/generated'; import test from 'tape'; @@ -168,10 +171,11 @@ test('test auction-house instructions', async (t) => { wallet.publicKey, ); - //const auction_house_fee_account_pre_balance = await connection.getBalance(feeAccount); + const auction_house_fee_account_pre_balance = await connection.getBalance(feeAccount); await amman.airdrop(connection, wallet.publicKey, 2); const wallet_sol_pre_balance = await connection.getBalance(wallet.publicKey); const deposit_amount = 1000; + const expected_balance_post_withdraw = 0; const depositAccounts: DepositInstructionAccounts = { wallet: wallet.publicKey, @@ -184,24 +188,58 @@ test('test auction-house instructions', async (t) => { auctionHouseFeeAccount: feeAccount, }; - const args: DepositInstructionArgs = { + const deposit_args: DepositInstructionArgs = { escrowPaymentBump: escrowPaymentBump, amount: deposit_amount, }; - const deposit_instruction = createDepositInstruction(depositAccounts, args); - const tx = new Transaction().add(deposit_instruction); - tx.recentBlockhash = (await connection.getRecentBlockhash()).blockhash; - /*const txId = */ await transactionHandler.sendAndConfirmTransaction(tx, [wallet], { + const deposit_instruction = createDepositInstruction(depositAccounts, deposit_args); + const deposit_tx = new Transaction().add(deposit_instruction); + deposit_tx.recentBlockhash = (await connection.getRecentBlockhash()).blockhash; + /*const txId = */ await transactionHandler.sendAndConfirmTransaction(deposit_tx, [wallet], { skipPreflight: false, }); - const deposit_fee_paid = (await connection.getFeeForMessage(tx.compileMessage())).value; + const deposit_fee_paid = (await connection.getFeeForMessage(deposit_tx.compileMessage())).value; const wallet_sol_post_balance = await connection.getBalance(wallet.publicKey); - const lsol_post_balance = await connection.getBalance(escrowPaymentAccount); + const escrow_post_balance = await connection.getBalance(escrowPaymentAccount); t.equal(wallet_sol_post_balance, wallet_sol_pre_balance - deposit_amount - deposit_fee_paid - REQUIRED_RENT_EXEMPTION, "wallet_sol_post_balance") - t.equal(lsol_post_balance, deposit_amount + REQUIRED_RENT_EXEMPTION, "escrow_sol_post_balance") + t.equal(escrow_post_balance, deposit_amount + REQUIRED_RENT_EXEMPTION, "escrow_sol_post_balance") + + // withdraw + const withdrawAccounts: WithdrawInstructionAccounts = { + wallet: wallet.publicKey, + receiptAccount: wallet.publicKey, + escrowPaymentAccount: escrowPaymentAccount, + treasuryMint: WRAPPED_SOL_MINT, + authority: authority.publicKey, + auctionHouse: auctionHouse, + auctionHouseFeeAccount: feeAccount, + } + + const withdraw_args: WithdrawInstructionArgs = { + escrowPaymentBump: escrowPaymentBump, + amount: deposit_amount + } + + const withdraw_instruction = createWithdrawInstruction(withdrawAccounts, withdraw_args) + const withdraw_tx = new Transaction().add(withdraw_instruction); + withdraw_tx.recentBlockhash = (await connection.getRecentBlockhash()).blockhash; + await transactionHandler.sendAndConfirmTransaction(withdraw_tx, [wallet], { + skipPreflight: false, + }); + + const withdraw_fee_paid = (await connection.getFeeForMessage(withdraw_tx.compileMessage())).value; + const escrow_post_withdraw_balance = await connection.getBalance(escrowPaymentAccount); + const wallet_sol_post_withdraw_balance = await connection.getBalance(wallet.publicKey); + + t.equal(escrow_post_withdraw_balance, expected_balance_post_withdraw, "escrow balance post withdraw == expected") + t.equal(wallet_sol_post_withdraw_balance, wallet_sol_post_balance - withdraw_fee_paid + deposit_amount + REQUIRED_RENT_EXEMPTION, "wallet balance post withdraw == expected"); + + const auction_house_fee_account_post_balance = await connection.getBalance(feeAccount); + t.equal(auction_house_fee_account_pre_balance, auction_house_fee_account_post_balance, "auction_house_fee_account_pre_balance == auction_house_fee_account_post_balance"); + t.end(); }); t.ok(true); }); From 2dca4ec2047c2d6859005299cc555e9ac8d8106d Mon Sep 17 00:00:00 2001 From: jdcaballerov Date: Wed, 10 Aug 2022 15:58:06 -0500 Subject: [PATCH 27/48] Fix test --- .../js/test/account.auction-house.test.ts | 60 ++++++++++++++----- 1 file changed, 44 insertions(+), 16 deletions(-) diff --git a/auction-house/js/test/account.auction-house.test.ts b/auction-house/js/test/account.auction-house.test.ts index cae2cbc621..42cddeb168 100644 --- a/auction-house/js/test/account.auction-house.test.ts +++ b/auction-house/js/test/account.auction-house.test.ts @@ -1,4 +1,11 @@ -import { AccountInfo, Connection, Keypair, PublicKey, Transaction, LAMPORTS_PER_SOL} from '@solana/web3.js'; +import { + AccountInfo, + Connection, + Keypair, + PublicKey, + Transaction, + LAMPORTS_PER_SOL, +} from '@solana/web3.js'; import { AuctionHouse, AuctionHouseArgs, @@ -21,7 +28,7 @@ const WRAPPED_SOL_MINT = new PublicKey('So11111111111111111111111111111111111111 export const AUCTION_HOUSE = 'auction_house'; export const FEE_PAYER = 'fee_payer'; export const TREASURY = 'treasury'; -const REQUIRED_RENT_EXEMPTION = 890_880 +const REQUIRED_RENT_EXEMPTION = 890_880; export const AUCTION_HOUSE_PROGRAM_ID = new PublicKey( 'hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk', @@ -123,10 +130,10 @@ test('test auction-house instructions', async (t) => { test('instruction auction-house: create auction-house', async (t) => { const treasuryWithdrawal = Keypair.generate(); const transactionHandler = amman.payerTransactionHandler(connection, authority); - const authority_aidrop_sol = 2 + const authority_aidrop_sol = 2; await amman.airdrop(connection, authority.publicKey, authority_aidrop_sol); const authority_balance = await connection.getBalance(authority.publicKey); - t.equal(authority_balance/LAMPORTS_PER_SOL, authority_aidrop_sol); + t.equal(authority_balance / LAMPORTS_PER_SOL, authority_aidrop_sol); const [auctionHouse, ahBump] = await getAuctionHouse(authority.publicKey, WRAPPED_SOL_MINT); const [feeAccount, feeBump] = await getAuctionHouseFeeAcct(auctionHouse); @@ -175,7 +182,7 @@ test('test auction-house instructions', async (t) => { await amman.airdrop(connection, wallet.publicKey, 2); const wallet_sol_pre_balance = await connection.getBalance(wallet.publicKey); const deposit_amount = 1000; - const expected_balance_post_withdraw = 0; + const expected_balance_post_withdraw = REQUIRED_RENT_EXEMPTION; const depositAccounts: DepositInstructionAccounts = { wallet: wallet.publicKey, @@ -204,8 +211,16 @@ test('test auction-house instructions', async (t) => { const wallet_sol_post_balance = await connection.getBalance(wallet.publicKey); const escrow_post_balance = await connection.getBalance(escrowPaymentAccount); - t.equal(wallet_sol_post_balance, wallet_sol_pre_balance - deposit_amount - deposit_fee_paid - REQUIRED_RENT_EXEMPTION, "wallet_sol_post_balance") - t.equal(escrow_post_balance, deposit_amount + REQUIRED_RENT_EXEMPTION, "escrow_sol_post_balance") + t.equal( + wallet_sol_post_balance, + wallet_sol_pre_balance - deposit_amount - deposit_fee_paid - REQUIRED_RENT_EXEMPTION, + 'wallet_sol_post_balance', + ); + t.equal( + escrow_post_balance, + deposit_amount + REQUIRED_RENT_EXEMPTION, + 'escrow_sol_post_balance', + ); // withdraw const withdrawAccounts: WithdrawInstructionAccounts = { @@ -216,29 +231,42 @@ test('test auction-house instructions', async (t) => { authority: authority.publicKey, auctionHouse: auctionHouse, auctionHouseFeeAccount: feeAccount, - } + }; const withdraw_args: WithdrawInstructionArgs = { escrowPaymentBump: escrowPaymentBump, - amount: deposit_amount - } + amount: deposit_amount, + }; - const withdraw_instruction = createWithdrawInstruction(withdrawAccounts, withdraw_args) + const withdraw_instruction = createWithdrawInstruction(withdrawAccounts, withdraw_args); const withdraw_tx = new Transaction().add(withdraw_instruction); withdraw_tx.recentBlockhash = (await connection.getRecentBlockhash()).blockhash; await transactionHandler.sendAndConfirmTransaction(withdraw_tx, [wallet], { skipPreflight: false, }); - const withdraw_fee_paid = (await connection.getFeeForMessage(withdraw_tx.compileMessage())).value; + const withdraw_fee_paid = (await connection.getFeeForMessage(withdraw_tx.compileMessage())) + .value; const escrow_post_withdraw_balance = await connection.getBalance(escrowPaymentAccount); const wallet_sol_post_withdraw_balance = await connection.getBalance(wallet.publicKey); - t.equal(escrow_post_withdraw_balance, expected_balance_post_withdraw, "escrow balance post withdraw == expected") - t.equal(wallet_sol_post_withdraw_balance, wallet_sol_post_balance - withdraw_fee_paid + deposit_amount + REQUIRED_RENT_EXEMPTION, "wallet balance post withdraw == expected"); - + t.equal( + escrow_post_withdraw_balance, + expected_balance_post_withdraw, + 'escrow balance post withdraw == expected', + ); + t.equal( + wallet_sol_post_withdraw_balance, + wallet_sol_post_balance - withdraw_fee_paid + deposit_amount - REQUIRED_RENT_EXEMPTION, + 'wallet balance post withdraw == expected', + ); + const auction_house_fee_account_post_balance = await connection.getBalance(feeAccount); - t.equal(auction_house_fee_account_pre_balance, auction_house_fee_account_post_balance, "auction_house_fee_account_pre_balance == auction_house_fee_account_post_balance"); + t.equal( + auction_house_fee_account_pre_balance, + auction_house_fee_account_post_balance, + 'auction_house_fee_account_pre_balance == auction_house_fee_account_post_balance', + ); t.end(); }); t.ok(true); From 6e3b125fc78060ba7cdd827bde4cbff4ad6202d3 Mon Sep 17 00:00:00 2001 From: jdcaballerov Date: Wed, 10 Aug 2022 16:09:42 -0500 Subject: [PATCH 28/48] Fix --- auction-house/js/test/account.auction-house.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auction-house/js/test/account.auction-house.test.ts b/auction-house/js/test/account.auction-house.test.ts index 42cddeb168..27b02f0c16 100644 --- a/auction-house/js/test/account.auction-house.test.ts +++ b/auction-house/js/test/account.auction-house.test.ts @@ -257,7 +257,7 @@ test('test auction-house instructions', async (t) => { ); t.equal( wallet_sol_post_withdraw_balance, - wallet_sol_post_balance - withdraw_fee_paid + deposit_amount - REQUIRED_RENT_EXEMPTION, + wallet_sol_post_balance - withdraw_fee_paid + deposit_amount, 'wallet balance post withdraw == expected', ); From 0305ed7de95256df2ee9ff87e122174d8c19052d Mon Sep 17 00:00:00 2001 From: jdcaballerov Date: Wed, 10 Aug 2022 16:25:24 -0500 Subject: [PATCH 29/48] Refactor --- .../js/test/account.auction-house.test.ts | 227 +----------------- .../js/test/integration.auction-house.test.js | 15 -- .../js/test/integration.auction-house.test.ts | 223 +++++++++++++++++ 3 files changed, 225 insertions(+), 240 deletions(-) delete mode 100644 auction-house/js/test/integration.auction-house.test.js create mode 100644 auction-house/js/test/integration.auction-house.test.ts diff --git a/auction-house/js/test/account.auction-house.test.ts b/auction-house/js/test/account.auction-house.test.ts index 27b02f0c16..af904821ff 100644 --- a/auction-house/js/test/account.auction-house.test.ts +++ b/auction-house/js/test/account.auction-house.test.ts @@ -1,87 +1,13 @@ -import { - AccountInfo, - Connection, - Keypair, - PublicKey, - Transaction, - LAMPORTS_PER_SOL, -} from '@solana/web3.js'; -import { - AuctionHouse, - AuctionHouseArgs, - CreateAuctionHouseInstructionAccounts, - CreateAuctionHouseInstructionArgs, - createCreateAuctionHouseInstruction, - DepositInstructionAccounts, - DepositInstructionArgs, - createDepositInstruction, - WithdrawInstructionAccounts, - WithdrawInstructionArgs, - createWithdrawInstruction, - // createAuctioneerWithdrawInstruction, -} from 'src/generated'; +import { AccountInfo, Keypair, PublicKey } from '@solana/web3.js'; +import { AuctionHouse, AuctionHouseArgs } from 'src/generated'; import test from 'tape'; import spok from 'spok'; -import { Amman } from '@metaplex-foundation/amman-client'; - -const WRAPPED_SOL_MINT = new PublicKey('So11111111111111111111111111111111111111112'); -export const AUCTION_HOUSE = 'auction_house'; -export const FEE_PAYER = 'fee_payer'; -export const TREASURY = 'treasury'; -const REQUIRED_RENT_EXEMPTION = 890_880; - -export const AUCTION_HOUSE_PROGRAM_ID = new PublicKey( - 'hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk', -); -const connectionURL = 'http://localhost:8899'; -export const amman = Amman.instance({ - knownLabels: { ['hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk']: 'Auction House' }, - log: console.log, -}); function quickKeypair(): [PublicKey, Uint8Array] { const kp = Keypair.generate(); return [kp.publicKey, kp.secretKey]; } -export const getAuctionHouse = async ( - creator: PublicKey, - treasuryMint: PublicKey, -): Promise<[PublicKey, number]> => { - return await PublicKey.findProgramAddress( - [Buffer.from(AUCTION_HOUSE), creator.toBuffer(), treasuryMint.toBuffer()], - AUCTION_HOUSE_PROGRAM_ID, - ); -}; - -export const getAuctionHouseFeeAcct = async ( - auctionHouse: PublicKey, -): Promise<[PublicKey, number]> => { - return await PublicKey.findProgramAddress( - [Buffer.from(AUCTION_HOUSE), auctionHouse.toBuffer(), Buffer.from(FEE_PAYER)], - AUCTION_HOUSE_PROGRAM_ID, - ); -}; - -export const getAuctionHouseTreasuryAcct = async ( - auctionHouse: PublicKey, -): Promise<[PublicKey, number]> => { - return await PublicKey.findProgramAddress( - [Buffer.from(AUCTION_HOUSE), auctionHouse.toBuffer(), Buffer.from(TREASURY)], - AUCTION_HOUSE_PROGRAM_ID, - ); -}; - -export const getAuctionHouseBuyerEscrow = async ( - auctionHouse: PublicKey, - wallet: PublicKey, -): Promise<[PublicKey, number]> => { - return await PublicKey.findProgramAddress( - [Buffer.from(AUCTION_HOUSE), auctionHouse.toBuffer(), wallet.toBuffer()], - AUCTION_HOUSE_PROGRAM_ID, - ); -}; - test('account auction-house: round trip serialization', async (t) => { const [creator] = quickKeypair(); const [auctionHouseTreasury] = quickKeypair(); @@ -122,152 +48,3 @@ test('account auction-house: round trip serialization', async (t) => { const actual = AuctionHouse.fromAccountInfo(info)[0]; spok(t, actual, expected); }); - -test('test auction-house instructions', async (t) => { - const authority = Keypair.generate(); - const connection = new Connection(connectionURL, 'confirmed'); - - test('instruction auction-house: create auction-house', async (t) => { - const treasuryWithdrawal = Keypair.generate(); - const transactionHandler = amman.payerTransactionHandler(connection, authority); - const authority_aidrop_sol = 2; - await amman.airdrop(connection, authority.publicKey, authority_aidrop_sol); - const authority_balance = await connection.getBalance(authority.publicKey); - t.equal(authority_balance / LAMPORTS_PER_SOL, authority_aidrop_sol); - - const [auctionHouse, ahBump] = await getAuctionHouse(authority.publicKey, WRAPPED_SOL_MINT); - const [feeAccount, feeBump] = await getAuctionHouseFeeAcct(auctionHouse); - const [treasuryAccount, treasuryBump] = await getAuctionHouseTreasuryAcct(auctionHouse); - - const accounts: CreateAuctionHouseInstructionAccounts = { - treasuryMint: WRAPPED_SOL_MINT, - payer: authority.publicKey, - authority: authority.publicKey, - feeWithdrawalDestination: authority.publicKey, - treasuryWithdrawalDestination: treasuryWithdrawal.publicKey, - treasuryWithdrawalDestinationOwner: treasuryWithdrawal.publicKey, - auctionHouse: auctionHouse, - auctionHouseFeeAccount: feeAccount, - auctionHouseTreasury: treasuryAccount, - }; - - const args: CreateAuctionHouseInstructionArgs = { - bump: ahBump, - feePayerBump: feeBump, - treasuryBump: treasuryBump, - sellerFeeBasisPoints: 250, - requiresSignOff: false, - canChangeSalePrice: false, - }; - const create_ah_instruction = createCreateAuctionHouseInstruction(accounts, args); - const tx = new Transaction().add(create_ah_instruction); - tx.recentBlockhash = (await connection.getRecentBlockhash()).blockhash; - const txId = await transactionHandler.sendAndConfirmTransaction(tx, [authority], { - skipPreflight: false, - }); - t.ok(txId); - t.end(); - }); - test('instruction auction-house: deposit and withdraw', async (t) => { - const wallet = Keypair.generate(); - const transactionHandler = amman.payerTransactionHandler(connection, wallet); - const [auctionHouse, {}] = await getAuctionHouse(authority.publicKey, WRAPPED_SOL_MINT); - const [feeAccount, {}] = await getAuctionHouseFeeAcct(auctionHouse); - const [escrowPaymentAccount, escrowPaymentBump] = await getAuctionHouseBuyerEscrow( - auctionHouse, - wallet.publicKey, - ); - - const auction_house_fee_account_pre_balance = await connection.getBalance(feeAccount); - await amman.airdrop(connection, wallet.publicKey, 2); - const wallet_sol_pre_balance = await connection.getBalance(wallet.publicKey); - const deposit_amount = 1000; - const expected_balance_post_withdraw = REQUIRED_RENT_EXEMPTION; - - const depositAccounts: DepositInstructionAccounts = { - wallet: wallet.publicKey, - paymentAccount: wallet.publicKey, - transferAuthority: authority.publicKey, - escrowPaymentAccount: escrowPaymentAccount, - treasuryMint: WRAPPED_SOL_MINT, - authority: authority.publicKey, - auctionHouse: auctionHouse, - auctionHouseFeeAccount: feeAccount, - }; - - const deposit_args: DepositInstructionArgs = { - escrowPaymentBump: escrowPaymentBump, - amount: deposit_amount, - }; - - const deposit_instruction = createDepositInstruction(depositAccounts, deposit_args); - const deposit_tx = new Transaction().add(deposit_instruction); - deposit_tx.recentBlockhash = (await connection.getRecentBlockhash()).blockhash; - /*const txId = */ await transactionHandler.sendAndConfirmTransaction(deposit_tx, [wallet], { - skipPreflight: false, - }); - - const deposit_fee_paid = (await connection.getFeeForMessage(deposit_tx.compileMessage())).value; - const wallet_sol_post_balance = await connection.getBalance(wallet.publicKey); - const escrow_post_balance = await connection.getBalance(escrowPaymentAccount); - - t.equal( - wallet_sol_post_balance, - wallet_sol_pre_balance - deposit_amount - deposit_fee_paid - REQUIRED_RENT_EXEMPTION, - 'wallet_sol_post_balance', - ); - t.equal( - escrow_post_balance, - deposit_amount + REQUIRED_RENT_EXEMPTION, - 'escrow_sol_post_balance', - ); - - // withdraw - const withdrawAccounts: WithdrawInstructionAccounts = { - wallet: wallet.publicKey, - receiptAccount: wallet.publicKey, - escrowPaymentAccount: escrowPaymentAccount, - treasuryMint: WRAPPED_SOL_MINT, - authority: authority.publicKey, - auctionHouse: auctionHouse, - auctionHouseFeeAccount: feeAccount, - }; - - const withdraw_args: WithdrawInstructionArgs = { - escrowPaymentBump: escrowPaymentBump, - amount: deposit_amount, - }; - - const withdraw_instruction = createWithdrawInstruction(withdrawAccounts, withdraw_args); - const withdraw_tx = new Transaction().add(withdraw_instruction); - withdraw_tx.recentBlockhash = (await connection.getRecentBlockhash()).blockhash; - await transactionHandler.sendAndConfirmTransaction(withdraw_tx, [wallet], { - skipPreflight: false, - }); - - const withdraw_fee_paid = (await connection.getFeeForMessage(withdraw_tx.compileMessage())) - .value; - const escrow_post_withdraw_balance = await connection.getBalance(escrowPaymentAccount); - const wallet_sol_post_withdraw_balance = await connection.getBalance(wallet.publicKey); - - t.equal( - escrow_post_withdraw_balance, - expected_balance_post_withdraw, - 'escrow balance post withdraw == expected', - ); - t.equal( - wallet_sol_post_withdraw_balance, - wallet_sol_post_balance - withdraw_fee_paid + deposit_amount, - 'wallet balance post withdraw == expected', - ); - - const auction_house_fee_account_post_balance = await connection.getBalance(feeAccount); - t.equal( - auction_house_fee_account_pre_balance, - auction_house_fee_account_post_balance, - 'auction_house_fee_account_pre_balance == auction_house_fee_account_post_balance', - ); - t.end(); - }); - t.ok(true); -}); diff --git a/auction-house/js/test/integration.auction-house.test.js b/auction-house/js/test/integration.auction-house.test.js deleted file mode 100644 index e1bdd62937..0000000000 --- a/auction-house/js/test/integration.auction-house.test.js +++ /dev/null @@ -1,15 +0,0 @@ -import test from 'tape'; -import { SetStore } from '../src/transactions'; -import { Store } from '../src/accounts/Store'; -import { connectionURL } from './utils'; -import { Connection, Keypair, PublicKey } from '@solana/web3.js'; -import { airdrop, PayerTransactionHandler } from '@metaplex-foundation/amman'; - -test('test_action', async (t) => { - const payer = Keypair.generate(); - const connection = new Connection(connectionURL, 'confirmed'); - const transactionHandler = new PayerTransactionHandler(connection, payer); - await airdrop(connection, payer.publicKey, 2); - - t.ok(True, 'Test runs'); -}); diff --git a/auction-house/js/test/integration.auction-house.test.ts b/auction-house/js/test/integration.auction-house.test.ts new file mode 100644 index 0000000000..8189a867ed --- /dev/null +++ b/auction-house/js/test/integration.auction-house.test.ts @@ -0,0 +1,223 @@ +import { Connection, Keypair, PublicKey, Transaction, LAMPORTS_PER_SOL } from '@solana/web3.js'; + +import { + CreateAuctionHouseInstructionAccounts, + CreateAuctionHouseInstructionArgs, + createCreateAuctionHouseInstruction, + DepositInstructionAccounts, + DepositInstructionArgs, + createDepositInstruction, + WithdrawInstructionAccounts, + WithdrawInstructionArgs, + createWithdrawInstruction, +} from 'src/generated'; +import test from 'tape'; +import { Amman } from '@metaplex-foundation/amman-client'; + +const WRAPPED_SOL_MINT = new PublicKey('So11111111111111111111111111111111111111112'); +export const AUCTION_HOUSE = 'auction_house'; +export const FEE_PAYER = 'fee_payer'; +export const TREASURY = 'treasury'; +const REQUIRED_RENT_EXEMPTION = 890_880; + +export const AUCTION_HOUSE_PROGRAM_ID = new PublicKey( + 'hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk', +); +const connectionURL = 'http://localhost:8899'; +export const amman = Amman.instance({ + knownLabels: { ['hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk']: 'Auction House' }, + log: console.log, +}); + +function quickKeypair(): [PublicKey, Uint8Array] { + const kp = Keypair.generate(); + return [kp.publicKey, kp.secretKey]; +} + +export const getAuctionHouse = async ( + creator: PublicKey, + treasuryMint: PublicKey, +): Promise<[PublicKey, number]> => { + return await PublicKey.findProgramAddress( + [Buffer.from(AUCTION_HOUSE), creator.toBuffer(), treasuryMint.toBuffer()], + AUCTION_HOUSE_PROGRAM_ID, + ); +}; + +export const getAuctionHouseFeeAcct = async ( + auctionHouse: PublicKey, +): Promise<[PublicKey, number]> => { + return await PublicKey.findProgramAddress( + [Buffer.from(AUCTION_HOUSE), auctionHouse.toBuffer(), Buffer.from(FEE_PAYER)], + AUCTION_HOUSE_PROGRAM_ID, + ); +}; + +export const getAuctionHouseTreasuryAcct = async ( + auctionHouse: PublicKey, +): Promise<[PublicKey, number]> => { + return await PublicKey.findProgramAddress( + [Buffer.from(AUCTION_HOUSE), auctionHouse.toBuffer(), Buffer.from(TREASURY)], + AUCTION_HOUSE_PROGRAM_ID, + ); +}; + +export const getAuctionHouseBuyerEscrow = async ( + auctionHouse: PublicKey, + wallet: PublicKey, +): Promise<[PublicKey, number]> => { + return await PublicKey.findProgramAddress( + [Buffer.from(AUCTION_HOUSE), auctionHouse.toBuffer(), wallet.toBuffer()], + AUCTION_HOUSE_PROGRAM_ID, + ); +}; + + +test('test auction-house instructions', async (t) => { + const authority = Keypair.generate(); + const connection = new Connection(connectionURL, 'confirmed'); + + test('instruction auction-house: create auction-house', async (t) => { + const treasuryWithdrawal = Keypair.generate(); + const transactionHandler = amman.payerTransactionHandler(connection, authority); + const authority_aidrop_sol = 2; + await amman.airdrop(connection, authority.publicKey, authority_aidrop_sol); + const authority_balance = await connection.getBalance(authority.publicKey); + t.equal(authority_balance / LAMPORTS_PER_SOL, authority_aidrop_sol); + + const [auctionHouse, ahBump] = await getAuctionHouse(authority.publicKey, WRAPPED_SOL_MINT); + const [feeAccount, feeBump] = await getAuctionHouseFeeAcct(auctionHouse); + const [treasuryAccount, treasuryBump] = await getAuctionHouseTreasuryAcct(auctionHouse); + + const accounts: CreateAuctionHouseInstructionAccounts = { + treasuryMint: WRAPPED_SOL_MINT, + payer: authority.publicKey, + authority: authority.publicKey, + feeWithdrawalDestination: authority.publicKey, + treasuryWithdrawalDestination: treasuryWithdrawal.publicKey, + treasuryWithdrawalDestinationOwner: treasuryWithdrawal.publicKey, + auctionHouse: auctionHouse, + auctionHouseFeeAccount: feeAccount, + auctionHouseTreasury: treasuryAccount, + }; + + const args: CreateAuctionHouseInstructionArgs = { + bump: ahBump, + feePayerBump: feeBump, + treasuryBump: treasuryBump, + sellerFeeBasisPoints: 250, + requiresSignOff: false, + canChangeSalePrice: false, + }; + const create_ah_instruction = createCreateAuctionHouseInstruction(accounts, args); + const tx = new Transaction().add(create_ah_instruction); + tx.recentBlockhash = (await connection.getRecentBlockhash()).blockhash; + const txId = await transactionHandler.sendAndConfirmTransaction(tx, [authority], { + skipPreflight: false, + }); + t.ok(txId); + t.end(); + }); + test('instruction auction-house: deposit and withdraw', async (t) => { + const wallet = Keypair.generate(); + const transactionHandler = amman.payerTransactionHandler(connection, wallet); + const [auctionHouse, {}] = await getAuctionHouse(authority.publicKey, WRAPPED_SOL_MINT); + const [feeAccount, {}] = await getAuctionHouseFeeAcct(auctionHouse); + const [escrowPaymentAccount, escrowPaymentBump] = await getAuctionHouseBuyerEscrow( + auctionHouse, + wallet.publicKey, + ); + + const auction_house_fee_account_pre_balance = await connection.getBalance(feeAccount); + await amman.airdrop(connection, wallet.publicKey, 2); + const wallet_sol_pre_balance = await connection.getBalance(wallet.publicKey); + const deposit_amount = 1000; + const expected_balance_post_withdraw = REQUIRED_RENT_EXEMPTION; + + const depositAccounts: DepositInstructionAccounts = { + wallet: wallet.publicKey, + paymentAccount: wallet.publicKey, + transferAuthority: authority.publicKey, + escrowPaymentAccount: escrowPaymentAccount, + treasuryMint: WRAPPED_SOL_MINT, + authority: authority.publicKey, + auctionHouse: auctionHouse, + auctionHouseFeeAccount: feeAccount, + }; + + const deposit_args: DepositInstructionArgs = { + escrowPaymentBump: escrowPaymentBump, + amount: deposit_amount, + }; + + const deposit_instruction = createDepositInstruction(depositAccounts, deposit_args); + const deposit_tx = new Transaction().add(deposit_instruction); + deposit_tx.recentBlockhash = (await connection.getRecentBlockhash()).blockhash; + /*const txId = */ await transactionHandler.sendAndConfirmTransaction(deposit_tx, [wallet], { + skipPreflight: false, + }); + + const deposit_fee_paid = (await connection.getFeeForMessage(deposit_tx.compileMessage())).value; + const wallet_sol_post_balance = await connection.getBalance(wallet.publicKey); + const escrow_post_balance = await connection.getBalance(escrowPaymentAccount); + + t.equal( + wallet_sol_post_balance, + wallet_sol_pre_balance - deposit_amount - deposit_fee_paid - REQUIRED_RENT_EXEMPTION, + 'wallet_sol_post_balance', + ); + t.equal( + escrow_post_balance, + deposit_amount + REQUIRED_RENT_EXEMPTION, + 'escrow_sol_post_balance', + ); + + // withdraw + const withdrawAccounts: WithdrawInstructionAccounts = { + wallet: wallet.publicKey, + receiptAccount: wallet.publicKey, + escrowPaymentAccount: escrowPaymentAccount, + treasuryMint: WRAPPED_SOL_MINT, + authority: authority.publicKey, + auctionHouse: auctionHouse, + auctionHouseFeeAccount: feeAccount, + }; + + const withdraw_args: WithdrawInstructionArgs = { + escrowPaymentBump: escrowPaymentBump, + amount: deposit_amount, + }; + + const withdraw_instruction = createWithdrawInstruction(withdrawAccounts, withdraw_args); + const withdraw_tx = new Transaction().add(withdraw_instruction); + withdraw_tx.recentBlockhash = (await connection.getRecentBlockhash()).blockhash; + await transactionHandler.sendAndConfirmTransaction(withdraw_tx, [wallet], { + skipPreflight: false, + }); + + const withdraw_fee_paid = (await connection.getFeeForMessage(withdraw_tx.compileMessage())) + .value; + const escrow_post_withdraw_balance = await connection.getBalance(escrowPaymentAccount); + const wallet_sol_post_withdraw_balance = await connection.getBalance(wallet.publicKey); + + t.equal( + escrow_post_withdraw_balance, + expected_balance_post_withdraw, + 'escrow balance post withdraw == expected', + ); + t.equal( + wallet_sol_post_withdraw_balance, + wallet_sol_post_balance - withdraw_fee_paid + deposit_amount, + 'wallet balance post withdraw == expected', + ); + + const auction_house_fee_account_post_balance = await connection.getBalance(feeAccount); + t.equal( + auction_house_fee_account_pre_balance, + auction_house_fee_account_post_balance, + 'auction_house_fee_account_pre_balance == auction_house_fee_account_post_balance', + ); + t.end(); + }); + t.ok(true); +}); From c99785e141e93ed0cb181632adbfa46304948e2a Mon Sep 17 00:00:00 2001 From: jdcaballerov Date: Wed, 10 Aug 2022 16:26:03 -0500 Subject: [PATCH 30/48] Fix --- auction-house/js/test/integration.auction-house.test.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/auction-house/js/test/integration.auction-house.test.ts b/auction-house/js/test/integration.auction-house.test.ts index 8189a867ed..34687a1900 100644 --- a/auction-house/js/test/integration.auction-house.test.ts +++ b/auction-house/js/test/integration.auction-house.test.ts @@ -29,11 +29,6 @@ export const amman = Amman.instance({ log: console.log, }); -function quickKeypair(): [PublicKey, Uint8Array] { - const kp = Keypair.generate(); - return [kp.publicKey, kp.secretKey]; -} - export const getAuctionHouse = async ( creator: PublicKey, treasuryMint: PublicKey, @@ -72,7 +67,6 @@ export const getAuctionHouseBuyerEscrow = async ( ); }; - test('test auction-house instructions', async (t) => { const authority = Keypair.generate(); const connection = new Connection(connectionURL, 'confirmed'); From 6172e0d814b187dd91fe8d5c073b2562be96c815 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Flak?= Date: Thu, 11 Aug 2022 01:59:29 +0200 Subject: [PATCH 31/48] try tape command --- auction-house/js/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auction-house/js/package.json b/auction-house/js/package.json index 899da4abb9..a759fd187e 100644 --- a/auction-house/js/package.json +++ b/auction-house/js/package.json @@ -18,7 +18,7 @@ "amman:stop": "DEBUG=\"amman*\" amman stop", "test:all": "yarn build && yarn amman:start && yarn test", "test:all-custom-ammanrc": "yarn build && yarn amman:start-custom-ammanrc ${0} && yarn test", - "test": "esr ./test/*.test.ts", + "test": "tape ./dist/test/*.test.js", "api:gen": "DEBUG='(solita|rustbin):(info|error)' solita", "lint": "eslint \"{src,test}/**/*.ts\" --format stylish", "fix:lint": "yarn lint --fix", From f66b36fc560b189cc98a87a0591a3090dc524634 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Flak?= Date: Thu, 11 Aug 2022 02:05:43 +0200 Subject: [PATCH 32/48] LOCALHOST from amman --- auction-house/js/test/integration.auction-house.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/auction-house/js/test/integration.auction-house.test.ts b/auction-house/js/test/integration.auction-house.test.ts index 34687a1900..bfbf1a5051 100644 --- a/auction-house/js/test/integration.auction-house.test.ts +++ b/auction-house/js/test/integration.auction-house.test.ts @@ -13,6 +13,8 @@ import { } from 'src/generated'; import test from 'tape'; import { Amman } from '@metaplex-foundation/amman-client'; +import { LOCALHOST } from '@metaplex-foundation/amman'; +const connectionURL = LOCALHOST; const WRAPPED_SOL_MINT = new PublicKey('So11111111111111111111111111111111111111112'); export const AUCTION_HOUSE = 'auction_house'; @@ -23,7 +25,6 @@ const REQUIRED_RENT_EXEMPTION = 890_880; export const AUCTION_HOUSE_PROGRAM_ID = new PublicKey( 'hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk', ); -const connectionURL = 'http://localhost:8899'; export const amman = Amman.instance({ knownLabels: { ['hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk']: 'Auction House' }, log: console.log, From bb384f80fa6c7d366e0b6ae9895f5338853ebd89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Flak?= Date: Thu, 11 Aug 2022 02:26:06 +0200 Subject: [PATCH 33/48] pkg.json fix --- auction-house/js/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auction-house/js/package.json b/auction-house/js/package.json index a759fd187e..f9a8f1920d 100644 --- a/auction-house/js/package.json +++ b/auction-house/js/package.json @@ -18,7 +18,7 @@ "amman:stop": "DEBUG=\"amman*\" amman stop", "test:all": "yarn build && yarn amman:start && yarn test", "test:all-custom-ammanrc": "yarn build && yarn amman:start-custom-ammanrc ${0} && yarn test", - "test": "tape ./dist/test/*.test.js", + "test": "tape ./test/*.test.ts", "api:gen": "DEBUG='(solita|rustbin):(info|error)' solita", "lint": "eslint \"{src,test}/**/*.ts\" --format stylish", "fix:lint": "yarn lint --fix", From 7fa1762cee0d0ab36b0e934d0fddb6220051e5bb Mon Sep 17 00:00:00 2001 From: jdcaballerov Date: Thu, 11 Aug 2022 07:07:10 -0500 Subject: [PATCH 34/48] Remove export --- .../js/test/integration.auction-house.test.ts | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/auction-house/js/test/integration.auction-house.test.ts b/auction-house/js/test/integration.auction-house.test.ts index bfbf1a5051..b1cfaa2fbd 100644 --- a/auction-house/js/test/integration.auction-house.test.ts +++ b/auction-house/js/test/integration.auction-house.test.ts @@ -17,20 +17,18 @@ import { LOCALHOST } from '@metaplex-foundation/amman'; const connectionURL = LOCALHOST; const WRAPPED_SOL_MINT = new PublicKey('So11111111111111111111111111111111111111112'); -export const AUCTION_HOUSE = 'auction_house'; -export const FEE_PAYER = 'fee_payer'; -export const TREASURY = 'treasury'; +const AUCTION_HOUSE = 'auction_house'; +const FEE_PAYER = 'fee_payer'; +const TREASURY = 'treasury'; const REQUIRED_RENT_EXEMPTION = 890_880; -export const AUCTION_HOUSE_PROGRAM_ID = new PublicKey( - 'hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk', -); -export const amman = Amman.instance({ +const AUCTION_HOUSE_PROGRAM_ID = new PublicKey('hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk'); +const amman = Amman.instance({ knownLabels: { ['hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk']: 'Auction House' }, log: console.log, }); -export const getAuctionHouse = async ( +const getAuctionHouse = async ( creator: PublicKey, treasuryMint: PublicKey, ): Promise<[PublicKey, number]> => { @@ -40,16 +38,14 @@ export const getAuctionHouse = async ( ); }; -export const getAuctionHouseFeeAcct = async ( - auctionHouse: PublicKey, -): Promise<[PublicKey, number]> => { +const getAuctionHouseFeeAcct = async (auctionHouse: PublicKey): Promise<[PublicKey, number]> => { return await PublicKey.findProgramAddress( [Buffer.from(AUCTION_HOUSE), auctionHouse.toBuffer(), Buffer.from(FEE_PAYER)], AUCTION_HOUSE_PROGRAM_ID, ); }; -export const getAuctionHouseTreasuryAcct = async ( +const getAuctionHouseTreasuryAcct = async ( auctionHouse: PublicKey, ): Promise<[PublicKey, number]> => { return await PublicKey.findProgramAddress( @@ -58,7 +54,7 @@ export const getAuctionHouseTreasuryAcct = async ( ); }; -export const getAuctionHouseBuyerEscrow = async ( +const getAuctionHouseBuyerEscrow = async ( auctionHouse: PublicKey, wallet: PublicKey, ): Promise<[PublicKey, number]> => { From 88412141d0c65b897b5729d58e0c69aae06a7249 Mon Sep 17 00:00:00 2001 From: jdcaballerov Date: Thu, 11 Aug 2022 07:30:50 -0500 Subject: [PATCH 35/48] test multiple bundle --- auction-house/js/package.json | 2 +- auction-house/js/test/integration.auction-house.test.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/auction-house/js/package.json b/auction-house/js/package.json index f9a8f1920d..432abe0a78 100644 --- a/auction-house/js/package.json +++ b/auction-house/js/package.json @@ -18,7 +18,7 @@ "amman:stop": "DEBUG=\"amman*\" amman stop", "test:all": "yarn build && yarn amman:start && yarn test", "test:all-custom-ammanrc": "yarn build && yarn amman:start-custom-ammanrc ${0} && yarn test", - "test": "tape ./test/*.test.ts", + "test": "esr ./test/**/*.ts", "api:gen": "DEBUG='(solita|rustbin):(info|error)' solita", "lint": "eslint \"{src,test}/**/*.ts\" --format stylish", "fix:lint": "yarn lint --fix", diff --git a/auction-house/js/test/integration.auction-house.test.ts b/auction-house/js/test/integration.auction-house.test.ts index b1cfaa2fbd..c55d635642 100644 --- a/auction-house/js/test/integration.auction-house.test.ts +++ b/auction-house/js/test/integration.auction-house.test.ts @@ -14,6 +14,7 @@ import { import test from 'tape'; import { Amman } from '@metaplex-foundation/amman-client'; import { LOCALHOST } from '@metaplex-foundation/amman'; + const connectionURL = LOCALHOST; const WRAPPED_SOL_MINT = new PublicKey('So11111111111111111111111111111111111111112'); From 58347aaf6b5856a0660ce26b333d67bc60721d0c Mon Sep 17 00:00:00 2001 From: jdcaballerov Date: Thu, 11 Aug 2022 07:44:35 -0500 Subject: [PATCH 36/48] Unify file --- ...ccount-instructions.auction-house.test.ts} | 59 ++++++++++++++++++- .../js/test/account.auction-house.test.ts | 50 ---------------- 2 files changed, 57 insertions(+), 52 deletions(-) rename auction-house/js/test/{integration.auction-house.test.ts => account-instructions.auction-house.test.ts} (84%) delete mode 100644 auction-house/js/test/account.auction-house.test.ts diff --git a/auction-house/js/test/integration.auction-house.test.ts b/auction-house/js/test/account-instructions.auction-house.test.ts similarity index 84% rename from auction-house/js/test/integration.auction-house.test.ts rename to auction-house/js/test/account-instructions.auction-house.test.ts index c55d635642..275bb8b071 100644 --- a/auction-house/js/test/integration.auction-house.test.ts +++ b/auction-house/js/test/account-instructions.auction-house.test.ts @@ -1,4 +1,14 @@ -import { Connection, Keypair, PublicKey, Transaction, LAMPORTS_PER_SOL } from '@solana/web3.js'; +import { + AccountInfo, + Connection, + Keypair, + PublicKey, + Transaction, + LAMPORTS_PER_SOL, +} from '@solana/web3.js'; +import { AuctionHouse, AuctionHouseArgs } from 'src/generated'; +import test from 'tape'; +import spok from 'spok'; import { CreateAuctionHouseInstructionAccounts, @@ -11,7 +21,6 @@ import { WithdrawInstructionArgs, createWithdrawInstruction, } from 'src/generated'; -import test from 'tape'; import { Amman } from '@metaplex-foundation/amman-client'; import { LOCALHOST } from '@metaplex-foundation/amman'; @@ -65,6 +74,52 @@ const getAuctionHouseBuyerEscrow = async ( ); }; +function quickKeypair(): [PublicKey, Uint8Array] { + const kp = Keypair.generate(); + return [kp.publicKey, kp.secretKey]; +} + +test('account auction-house: round trip serialization', async (t) => { + const [creator] = quickKeypair(); + const [auctionHouseTreasury] = quickKeypair(); + const [treasuryWithdrawalDestination] = quickKeypair(); + const [feeWithdrawalDestination] = quickKeypair(); + const [treasuryMint] = quickKeypair(); + + const args: AuctionHouseArgs = { + auctionHouseFeeAccount: creator, + auctionHouseTreasury, + treasuryWithdrawalDestination, + feeWithdrawalDestination, + treasuryMint, + authority: creator, + creator, + bump: 0, + treasuryBump: 1, + feePayerBump: 2, + sellerFeeBasisPoints: 3, + requiresSignOff: false, + canChangeSalePrice: true, + escrowPaymentBump: 255, + hasAuctioneer: false, + auctioneerAddress: PublicKey.default, + scopes: Array(7).fill(false), // constant size field in the contract + }; + + const expected = AuctionHouse.fromArgs(args); + const [data] = expected.serialize(); + + const info: AccountInfo = { + executable: false, + data, + owner: creator, + lamports: 1000, + }; + + const actual = AuctionHouse.fromAccountInfo(info)[0]; + spok(t, actual, expected); +}); + test('test auction-house instructions', async (t) => { const authority = Keypair.generate(); const connection = new Connection(connectionURL, 'confirmed'); diff --git a/auction-house/js/test/account.auction-house.test.ts b/auction-house/js/test/account.auction-house.test.ts deleted file mode 100644 index af904821ff..0000000000 --- a/auction-house/js/test/account.auction-house.test.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { AccountInfo, Keypair, PublicKey } from '@solana/web3.js'; -import { AuctionHouse, AuctionHouseArgs } from 'src/generated'; -import test from 'tape'; -import spok from 'spok'; - -function quickKeypair(): [PublicKey, Uint8Array] { - const kp = Keypair.generate(); - return [kp.publicKey, kp.secretKey]; -} - -test('account auction-house: round trip serialization', async (t) => { - const [creator] = quickKeypair(); - const [auctionHouseTreasury] = quickKeypair(); - const [treasuryWithdrawalDestination] = quickKeypair(); - const [feeWithdrawalDestination] = quickKeypair(); - const [treasuryMint] = quickKeypair(); - - const args: AuctionHouseArgs = { - auctionHouseFeeAccount: creator, - auctionHouseTreasury, - treasuryWithdrawalDestination, - feeWithdrawalDestination, - treasuryMint, - authority: creator, - creator, - bump: 0, - treasuryBump: 1, - feePayerBump: 2, - sellerFeeBasisPoints: 3, - requiresSignOff: false, - canChangeSalePrice: true, - escrowPaymentBump: 255, - hasAuctioneer: false, - auctioneerAddress: PublicKey.default, - scopes: Array(7).fill(false), // constant size field in the contract - }; - - const expected = AuctionHouse.fromArgs(args); - const [data] = expected.serialize(); - - const info: AccountInfo = { - executable: false, - data, - owner: creator, - lamports: 1000, - }; - - const actual = AuctionHouse.fromAccountInfo(info)[0]; - spok(t, actual, expected); -}); From 2aa251e35868af63cfa44a567cd56062c87ec6f5 Mon Sep 17 00:00:00 2001 From: jdcaballerov Date: Thu, 11 Aug 2022 08:58:34 -0500 Subject: [PATCH 37/48] Use signoff --- .../js/test/account-instructions.auction-house.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auction-house/js/test/account-instructions.auction-house.test.ts b/auction-house/js/test/account-instructions.auction-house.test.ts index 275bb8b071..6172d03af3 100644 --- a/auction-house/js/test/account-instructions.auction-house.test.ts +++ b/auction-house/js/test/account-instructions.auction-house.test.ts @@ -153,7 +153,7 @@ test('test auction-house instructions', async (t) => { feePayerBump: feeBump, treasuryBump: treasuryBump, sellerFeeBasisPoints: 250, - requiresSignOff: false, + requiresSignOff: true, canChangeSalePrice: false, }; const create_ah_instruction = createCreateAuctionHouseInstruction(accounts, args); From efa781c51fca840f737477a83967d3a1dce6aefe Mon Sep 17 00:00:00 2001 From: jdcaballerov Date: Thu, 11 Aug 2022 09:11:52 -0500 Subject: [PATCH 38/48] Add auth signature --- .../test/account-instructions.auction-house.test.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/auction-house/js/test/account-instructions.auction-house.test.ts b/auction-house/js/test/account-instructions.auction-house.test.ts index 6172d03af3..87ba9bb494 100644 --- a/auction-house/js/test/account-instructions.auction-house.test.ts +++ b/auction-house/js/test/account-instructions.auction-house.test.ts @@ -200,9 +200,13 @@ test('test auction-house instructions', async (t) => { const deposit_instruction = createDepositInstruction(depositAccounts, deposit_args); const deposit_tx = new Transaction().add(deposit_instruction); deposit_tx.recentBlockhash = (await connection.getRecentBlockhash()).blockhash; - /*const txId = */ await transactionHandler.sendAndConfirmTransaction(deposit_tx, [wallet], { - skipPreflight: false, - }); + /*const txId = */ await transactionHandler.sendAndConfirmTransaction( + deposit_tx, + [wallet, authority], + { + skipPreflight: false, + }, + ); const deposit_fee_paid = (await connection.getFeeForMessage(deposit_tx.compileMessage())).value; const wallet_sol_post_balance = await connection.getBalance(wallet.publicKey); @@ -238,7 +242,7 @@ test('test auction-house instructions', async (t) => { const withdraw_instruction = createWithdrawInstruction(withdrawAccounts, withdraw_args); const withdraw_tx = new Transaction().add(withdraw_instruction); withdraw_tx.recentBlockhash = (await connection.getRecentBlockhash()).blockhash; - await transactionHandler.sendAndConfirmTransaction(withdraw_tx, [wallet], { + await transactionHandler.sendAndConfirmTransaction(withdraw_tx, [wallet, authority], { skipPreflight: false, }); From 0f88fb47e937b03e471ccf7dc16cfea571537f97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Flak?= Date: Thu, 11 Aug 2022 20:54:36 +0200 Subject: [PATCH 39/48] Reference getAuctionHouse... fns from cli --- auction-house/cli/src/helpers/accounts.ts | 3 ++ auction-house/cli/src/helpers/instructions.ts | 3 ++ auction-house/cli/src/helpers/various.ts | 4 ++ auction-house/cli/src/tsconfig.json | 3 +- auction-house/cli/tsconfig.json | 2 +- ...account-instructions.auction-house.test.ts | 47 +++---------------- auction-house/js/tsconfig.json | 4 +- 7 files changed, 22 insertions(+), 44 deletions(-) diff --git a/auction-house/cli/src/helpers/accounts.ts b/auction-house/cli/src/helpers/accounts.ts index 29c793902d..36aa89178c 100644 --- a/auction-house/cli/src/helpers/accounts.ts +++ b/auction-house/cli/src/helpers/accounts.ts @@ -1,3 +1,6 @@ +// @ts-nocheck +// Errors from this file broke the build for +// auction-house/js which references it in tests import { Keypair, PublicKey, diff --git a/auction-house/cli/src/helpers/instructions.ts b/auction-house/cli/src/helpers/instructions.ts index 3a8de16057..489a2c3907 100644 --- a/auction-house/cli/src/helpers/instructions.ts +++ b/auction-house/cli/src/helpers/instructions.ts @@ -1,3 +1,6 @@ +// @ts-nocheck +// Errors from this file broke the build for +// auction-house/js which references it in tests import { PublicKey, SystemProgram, diff --git a/auction-house/cli/src/helpers/various.ts b/auction-house/cli/src/helpers/various.ts index 734e038e40..7ddab66ac9 100644 --- a/auction-house/cli/src/helpers/various.ts +++ b/auction-house/cli/src/helpers/various.ts @@ -1,3 +1,6 @@ +// @ts-nocheck +// Errors from this file broke the build for +// auction-house/js which references it in tests import { LAMPORTS_PER_SOL, AccountInfo, @@ -401,6 +404,7 @@ export function getCluster(name: string): string { } throw new Error(`Could not get cluster: ${name}`); + //@ts-ignore return null; } diff --git a/auction-house/cli/src/tsconfig.json b/auction-house/cli/src/tsconfig.json index e5dc17b288..5cd1deb88b 100644 --- a/auction-house/cli/src/tsconfig.json +++ b/auction-house/cli/src/tsconfig.json @@ -16,7 +16,8 @@ "suppressImplicitAnyIndexErrors": true, "resolveJsonModule": true, "lib": ["dom", "es2019"], - "types": ["jest", "node", "webgl2"] + "types": ["jest", "node", "webgl2"], + "skipLibCheck": true }, "exclude": ["node_modules", "typings/browser", "typings/browser.d.ts"], "atom": { diff --git a/auction-house/cli/tsconfig.json b/auction-house/cli/tsconfig.json index e9dd44415d..3c67c7fdc2 100644 --- a/auction-house/cli/tsconfig.json +++ b/auction-house/cli/tsconfig.json @@ -10,7 +10,7 @@ "allowSyntheticDefaultImports": true, "experimentalDecorators": true, "emitDecoratorMetadata": true, - "noImplicitAny": true, + "noImplicitAny": false, "typeRoots": ["types", "node_modules/@types"] }, "include": ["src/**/*"] diff --git a/auction-house/js/test/account-instructions.auction-house.test.ts b/auction-house/js/test/account-instructions.auction-house.test.ts index 87ba9bb494..d651fca579 100644 --- a/auction-house/js/test/account-instructions.auction-house.test.ts +++ b/auction-house/js/test/account-instructions.auction-house.test.ts @@ -9,6 +9,12 @@ import { import { AuctionHouse, AuctionHouseArgs } from 'src/generated'; import test from 'tape'; import spok from 'spok'; +import { + getAuctionHouse, + getAuctionHouseFeeAcct, + getAuctionHouseTreasuryAcct, + getAuctionHouseBuyerEscrow, +} from '../cli/src/helpers/accounts'; import { CreateAuctionHouseInstructionAccounts, @@ -27,53 +33,14 @@ import { LOCALHOST } from '@metaplex-foundation/amman'; const connectionURL = LOCALHOST; const WRAPPED_SOL_MINT = new PublicKey('So11111111111111111111111111111111111111112'); -const AUCTION_HOUSE = 'auction_house'; -const FEE_PAYER = 'fee_payer'; -const TREASURY = 'treasury'; const REQUIRED_RENT_EXEMPTION = 890_880; const AUCTION_HOUSE_PROGRAM_ID = new PublicKey('hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk'); const amman = Amman.instance({ - knownLabels: { ['hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk']: 'Auction House' }, + knownLabels: { [AUCTION_HOUSE_PROGRAM_ID.toString()]: 'Auction House' }, log: console.log, }); -const getAuctionHouse = async ( - creator: PublicKey, - treasuryMint: PublicKey, -): Promise<[PublicKey, number]> => { - return await PublicKey.findProgramAddress( - [Buffer.from(AUCTION_HOUSE), creator.toBuffer(), treasuryMint.toBuffer()], - AUCTION_HOUSE_PROGRAM_ID, - ); -}; - -const getAuctionHouseFeeAcct = async (auctionHouse: PublicKey): Promise<[PublicKey, number]> => { - return await PublicKey.findProgramAddress( - [Buffer.from(AUCTION_HOUSE), auctionHouse.toBuffer(), Buffer.from(FEE_PAYER)], - AUCTION_HOUSE_PROGRAM_ID, - ); -}; - -const getAuctionHouseTreasuryAcct = async ( - auctionHouse: PublicKey, -): Promise<[PublicKey, number]> => { - return await PublicKey.findProgramAddress( - [Buffer.from(AUCTION_HOUSE), auctionHouse.toBuffer(), Buffer.from(TREASURY)], - AUCTION_HOUSE_PROGRAM_ID, - ); -}; - -const getAuctionHouseBuyerEscrow = async ( - auctionHouse: PublicKey, - wallet: PublicKey, -): Promise<[PublicKey, number]> => { - return await PublicKey.findProgramAddress( - [Buffer.from(AUCTION_HOUSE), auctionHouse.toBuffer(), wallet.toBuffer()], - AUCTION_HOUSE_PROGRAM_ID, - ); -}; - function quickKeypair(): [PublicKey, Uint8Array] { const kp = Keypair.generate(); return [kp.publicKey, kp.secretKey]; diff --git a/auction-house/js/tsconfig.json b/auction-house/js/tsconfig.json index b070394b14..15fd1ab6a8 100644 --- a/auction-house/js/tsconfig.json +++ b/auction-house/js/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "./tsconfig.build.json", "compilerOptions": { - "rootDir": "." + "rootDirs": [".", ".."] }, - "include": ["./src", "test"] + "include": ["./src", "test", "../cli/js"] } From 9641488d03d3a9e88d3b298347f8f530800a4bb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Flak?= Date: Thu, 11 Aug 2022 21:16:46 +0200 Subject: [PATCH 40/48] remove tsignore --- auction-house/cli/src/helpers/various.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/auction-house/cli/src/helpers/various.ts b/auction-house/cli/src/helpers/various.ts index 7ddab66ac9..8c96deda6c 100644 --- a/auction-house/cli/src/helpers/various.ts +++ b/auction-house/cli/src/helpers/various.ts @@ -404,7 +404,6 @@ export function getCluster(name: string): string { } throw new Error(`Could not get cluster: ${name}`); - //@ts-ignore return null; } From 074e3f40e940b74ef245d5073fde7b0415b8d3b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Flak?= Date: Thu, 11 Aug 2022 21:45:20 +0200 Subject: [PATCH 41/48] path fix --- .../js/test/account-instructions.auction-house.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auction-house/js/test/account-instructions.auction-house.test.ts b/auction-house/js/test/account-instructions.auction-house.test.ts index d651fca579..dd247e1110 100644 --- a/auction-house/js/test/account-instructions.auction-house.test.ts +++ b/auction-house/js/test/account-instructions.auction-house.test.ts @@ -14,7 +14,7 @@ import { getAuctionHouseFeeAcct, getAuctionHouseTreasuryAcct, getAuctionHouseBuyerEscrow, -} from '../cli/src/helpers/accounts'; +} from '../../cli/src/helpers/accounts'; import { CreateAuctionHouseInstructionAccounts, From 3d8b751cb0a7eb22b0da506b18e3b9d832fe3ada Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Flak?= Date: Thu, 11 Aug 2022 21:58:07 +0200 Subject: [PATCH 42/48] remove utils --- auction-house/js/test/utils.ts | 125 --------------------------------- 1 file changed, 125 deletions(-) delete mode 100644 auction-house/js/test/utils.ts diff --git a/auction-house/js/test/utils.ts b/auction-house/js/test/utils.ts deleted file mode 100644 index 2a8f9610f7..0000000000 --- a/auction-house/js/test/utils.ts +++ /dev/null @@ -1,125 +0,0 @@ -import path from 'path'; -import { Keypair, PublicKey, TransactionCtorFields } from '@solana/web3.js'; -import { tmpdir } from 'os'; -import { readFileSync } from 'fs'; -import { LOCALHOST } from '@metaplex-foundation/amman'; - -export const connectionURL = LOCALHOST; - -// Devnet fee payer -export const FEE_PAYER = Keypair.fromSecretKey( - new Uint8Array([ - 225, 60, 117, 68, 123, 252, 1, 200, 41, 251, 54, 121, 6, 167, 204, 18, 140, 168, 206, 74, 254, - 156, 230, 10, 212, 124, 162, 85, 120, 78, 122, 106, 187, 209, 148, 182, 34, 149, 175, 173, 192, - 85, 175, 252, 231, 130, 76, 40, 175, 177, 44, 111, 250, 168, 3, 236, 149, 34, 236, 19, 46, 9, - 66, 138, - ]), -); - -export const STORE_OWNER_PUBKEY = new PublicKey('7hKMAoCYJuBnBLmVTjswu7m6jcwyE8MYAP5hPijUT6nd'); -export const STORE_PUBKEY = new PublicKey('DNQzo4Aggw8PneX7BGY7niEkB8wfNJwx6DpV9BLBUUFF'); -export const AUCTION_MANAGER_PUBKEY = new PublicKey('Gjd1Mo8KLEgywxMKaDRhaoD2Fu8bzoVLZ8H7v761XXkf'); -export const AUCTION_PUBKEY = new PublicKey('BTE7AqJn4aG2MKZnaSTEgbQ4aCgPTDmphs5uxDnuDqvQ'); -export const AUCTION_EXTENDED_PUBKEY = new PublicKey( - '9nUKpweEWpk5mQiBzxYWB62dhQR5NtaZDShccqsWnPGa', -); -export const VAULT_PUBKEY = new PublicKey('BE43QppYzwWVVSobScMbPgqKogPHsHQoogXgLH3ZTFtW'); -export const METADATA_PUBKEY = new PublicKey('CZkFeERacU42qjApPyjamS13fNtz7y1wYLu5jyLpN1WL'); -export const MASTER_EDITION_PUBKEY = new PublicKey('EZ5xB174dcz982WXV2aNr4zSW5ywAH3gP5Lbj8CuRMw4'); -export const PACKSET_PUBKEY = new PublicKey('AN1bTGLCLSoSTJMeBPa7KGRDF5BpbfvD7oA42ZMq27Ru'); -export const PACKCARD_PUBKEY = new PublicKey('BVrBhek71ZDDPQ8tYucBiEKxYmmtQLioF3eJJnhH6md4'); -export const PACKVOUCHER_PUBKEY = new PublicKey('Ah6ngnNfhzKFfMPtiK5BeQ4mF5Nzwv1bwtbAEgMYH6Dp'); -export const PROVING_PROCESS_PUBKEY = new PublicKey('HCzXvi3L1xdkFp5jafadFGzbirua9U4r4ePiXvcqH81R'); - -export const VAULT_AUTHORITY_PUBKEY = new PublicKey('AHsj4FffgTUYUVDjwBRGmiAsJcpWxX3YXZB8qsuew79t'); -export const FRACTIONAL_MINT_PUBKEY = new PublicKey('1Qyhk9Pm1XktCN8RptQrwe9KnQLmiD7E58LpvqcnSV8'); -export const REDEEM_TREASURY_PUBKEY = new PublicKey('vkXyVgeQaivApFsUXLMcQcVK7FGzkhAyR73FJ5YGnnb'); -export const FRACTIONAL_TREASURY_PUBKEY = new PublicKey( - '5nxC9KnUSqr5dNQoPN7xhKfmzS48znM3zfNqcgdKYXrh', -); -export const PRICING_LOOKUP_ADDRESS_PUBKEY = new PublicKey( - '7csPZBkT87N7x7aVrALjLBeDjCs7vcymazXVxoS3fmSf', -); -export const FRACTION_MINT_PUBKEY = new PublicKey('BjrKGZgGL7sqv5aAUxp6ZafsWGKku9UZcMioQqASSaFB'); -export const FRACTION_TREASURY_PUBKEY = new PublicKey( - '3SZUEd9qtoKCyLW8uT8z25k7kZnMmwtdLQYjQAYRZHRp', -); -export const FRACTION_MINT_AUTHORITY_PUBKEY = new PublicKey( - '693Dn6MCsBYS4SkpSAXdhEvWNDooUHyF8KvvniEy4aBM', -); -export const TOKEN_MINT_PUBKEY = new PublicKey('8epm7eTwoEpw36QF1puxkzsRzkVp45paRXnohbPemjmK'); -export const TOKEN_ACCOUNT_PUBKEY = new PublicKey('4mpzrMQo8wgBtUHDVZLPeR9i58mbHVFNT9ef8sSzUohS'); -export const TOKEN_STORE_ACCOUNT_PUBKEY = new PublicKey( - 'B8ZH2ndZk1ueJvu56UNThAdjGXkfs1PyC5DwupWbwfZ3', -); -export const TRANSFER_AUTHORITY_PUBKEY = new PublicKey( - '8azYDQNycrRkv2r7amatTy3dyD6RrSw3zZsJvymzWE3E', -); -export const SAFETY_DEPOSIT_BOX_PUBKEY = new PublicKey( - '7pgXQDqVpiuj7TqbJKn9bW7ipg8U2uG5kY7kXNdNiTQd', -); -export const OUTSTANDING_SHARE_TOKEN_ACCOUNT_PUBKEY = new PublicKey( - '5Q9THrE74FsopHjASfj7RLqR36RgYbKhD1shoPoDDCCZ', -); -export const OUTSTANDING_SHARES_ACCOUNT_PUBKEY = new PublicKey( - '4Q2A27cS5DihPnerndsFZ6MxSTzjzfsjuQtS2hV3VXTT', -); -export const BURN_AUTHORITY_PUBKEY = new PublicKey('4d4xRorridzBRApmoprSaB74Tgv4TN7TqhqfUeQB2dvw'); -export const NEW_VAULT_AUTHORITY_PUBKEY = new PublicKey( - 'Hi4wFQcmHKioVKvsL3NeYy9gANkZF9RQ9ZvTU7FdHP9s', -); -export const EXTERNAL_PRICE_ACCOUNT_PUBKEY = new PublicKey( - '78qz3gehg9YqktdaYt6o56DSUPFQ41tLMACHpnFjdYdS', -); -export const PAYING_TOKEN_ACCOUNT_PUBKEY = new PublicKey( - '8e6FHYEx7rfv1weRKrerjwuDzVn89LSjDsfXZcvWYDYW', -); -export const CURRENT_AUTHORITY_PUBKEY = new PublicKey( - 'EyBYD5b1A2xQAHJ8nUn11nHY8VrPV3Scg4mXZyjCB61f', -); -export const NEW_AUTHORITY_PUBKEY = new PublicKey('5jF6nAQ5GTK8rsdzW8hGCEsWjY9YCV2jXCwZ854BPsWz'); -export const RECENT_ISH_BLOCKHASH = '9qb2wMGnvBgVdp2dhJdeo5hgko9nLHxXg7GqXPgAFYCU'; -export const PROCEEDS_ACCOUNT_PUBKEY = new PublicKey( - 'GvJVHbk8pEzHwaeHeaoUrnBbsaUcDHHRVjKqP15UcShf', -); -export const SOURCE_PUBKEY = new PublicKey('4CkQJBxhU8EZ2UjhigbtdaPbpTe6mqf811fipYBFbSYN'); -export const DESTINATION_PUBKEY = new PublicKey('CZXESU6tu9m4YDs2wfQFbXmjbaDtJKBgurgYzGmeoArh'); - -export const VAULT_EXTENRNAL_PRICE_ACCOUNT = new PublicKey( - '58S2MNcuS79ncBc5xi1T8jdS98jcXJbXqM5UvGvgmwcr', -); - -export const mockTransaction: TransactionCtorFields = { - feePayer: new PublicKey('7J6QvJGCB22vDvYB33ikrWCXRBRsFY74ntAArSK4KJUn'), - recentBlockhash: RECENT_ISH_BLOCKHASH, -}; -export const BID_METADATA_PUBKEY = new PublicKey('CZkFeERacU42qjGTPyjamS13fNtz7y1wYLu5jyLpN1WL'); -export const BID_REDEMPTION_PUBKEY = new PublicKey('4CkQJBxhU8EZ1UjhfgbtdaPbpTe6mqf811fipYBFbSYN'); -export const SAFETY_DEPOSIT_TOKEN_STORE_PUBKEY = new PublicKey( - '4CkQJBxhU8EZ1UjhfgbtdaPbpTe6mqf811fipYBFbSNM', -); -export const SAFETY_DEPOSIT_CONFIG_PUBKEY = new PublicKey( - '4CkBUBxhU8EZ1UjhfgbtdaPbpTe6mqf811fipYBFbSNM', -); -export const NEW_EDITION_PUBKEY = new PublicKey('4CkBUBxhU8EZ1UjhfgbtdaPbpTe6mqf822fipYBFbSNM'); -export const NEW_METADATA_PUBKEY = new PublicKey('5jF6nAQ5GTK8rsdzW8hGCEsWjY9YCV2jXCwZ111BPsWz'); -export const EDITION_MARK_PUBKEY = new PublicKey('78qz3gehg9YqktdaYt6o71DSUPFQ41tLMACHpnFjdYdS'); -export const PRIZE_TRACKING_TICKET_PUBKEY = new PublicKey( - '78qz3gehg9YqktdaYt6o99DSUPFQ41tLMACHpnFjdYdS', -); - -export const projectRoot = path.resolve(__dirname, '..', '..'); -export const tmpTestDir = path.resolve(tmpdir(), 'test'); - -export const serializeConfig = { verifySignatures: false, requireAllSignatures: false }; -export async function sleep(ms: number) { - return new Promise((resolve) => setTimeout(resolve, ms)); -} - -export function getUserKeypairFromFile(keypairPath: string) { - const arr = readFileSync(path.resolve(keypairPath), { - encoding: 'utf-8', - }); - const u8Array = Uint8Array.from(JSON.parse(arr)); - return Keypair.fromSecretKey(u8Array); -} From 066828a9471165cbd04d003c1e1a47d7c47d239b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Flak?= Date: Thu, 11 Aug 2022 22:02:38 +0200 Subject: [PATCH 43/48] Final cleanup --- .../account-instructions.auction-house.test.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/auction-house/js/test/account-instructions.auction-house.test.ts b/auction-house/js/test/account-instructions.auction-house.test.ts index dd247e1110..00c66a4a5c 100644 --- a/auction-house/js/test/account-instructions.auction-house.test.ts +++ b/auction-house/js/test/account-instructions.auction-house.test.ts @@ -167,7 +167,7 @@ test('test auction-house instructions', async (t) => { const deposit_instruction = createDepositInstruction(depositAccounts, deposit_args); const deposit_tx = new Transaction().add(deposit_instruction); deposit_tx.recentBlockhash = (await connection.getRecentBlockhash()).blockhash; - /*const txId = */ await transactionHandler.sendAndConfirmTransaction( + await transactionHandler.sendAndConfirmTransaction( deposit_tx, [wallet, authority], { @@ -176,18 +176,18 @@ test('test auction-house instructions', async (t) => { ); const deposit_fee_paid = (await connection.getFeeForMessage(deposit_tx.compileMessage())).value; - const wallet_sol_post_balance = await connection.getBalance(wallet.publicKey); - const escrow_post_balance = await connection.getBalance(escrowPaymentAccount); + const wallet_sol_post_deposit_balance = await connection.getBalance(wallet.publicKey); + const escrow_post_deposit_balance = await connection.getBalance(escrowPaymentAccount); t.equal( - wallet_sol_post_balance, + wallet_sol_post_deposit_balance, wallet_sol_pre_balance - deposit_amount - deposit_fee_paid - REQUIRED_RENT_EXEMPTION, - 'wallet_sol_post_balance', + 'wallet_sol_post_deposit_balance', ); t.equal( - escrow_post_balance, + escrow_post_deposit_balance, deposit_amount + REQUIRED_RENT_EXEMPTION, - 'escrow_sol_post_balance', + 'escrow_sol_post_deposit_balance', ); // withdraw @@ -225,7 +225,7 @@ test('test auction-house instructions', async (t) => { ); t.equal( wallet_sol_post_withdraw_balance, - wallet_sol_post_balance - withdraw_fee_paid + deposit_amount, + wallet_sol_post_deposit_balance - withdraw_fee_paid + deposit_amount, 'wallet balance post withdraw == expected', ); From 73d61c821f5e7c82fc12963a71722d90ec7ff716 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Flak?= Date: Thu, 11 Aug 2022 22:28:10 +0200 Subject: [PATCH 44/48] build AH CLI in CI --- .github/actions/yarn-install-and-build/action.yml | 14 ++++++++++++++ .github/workflows/integration-auction-house.yml | 7 +++++++ auction-house/cli/package.json | 3 ++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/.github/actions/yarn-install-and-build/action.yml b/.github/actions/yarn-install-and-build/action.yml index bacd207c31..c0e0be7979 100644 --- a/.github/actions/yarn-install-and-build/action.yml +++ b/.github/actions/yarn-install-and-build/action.yml @@ -28,6 +28,10 @@ inputs: description: If true it will build the auction_house package required: false default: false + build_auction_house_cli: + description: If true it will build the auction_house CLI package + required: false + default: false runs: using: composite @@ -97,6 +101,16 @@ runs: working-directory: ./auction-house/js shell: bash + - name: Install and Build auction-house CLI + if: inputs.build_auction_house_cli == 'true' + run: | + echo 'Install and Build auction_house CLI: yarn install' + yarn install + echo 'Install and Build auction_house CLI: yarn build' + yarn build + working-directory: ./auction-house/cli + shell: bash + ############## # Build Contract ############## diff --git a/.github/workflows/integration-auction-house.yml b/.github/workflows/integration-auction-house.yml index 6cf9c02d74..499df83dfc 100644 --- a/.github/workflows/integration-auction-house.yml +++ b/.github/workflows/integration-auction-house.yml @@ -67,6 +67,13 @@ jobs: working_dir: ./auction-house/js build_auction_house: true + # Install CLI deps + - uses: ./.github/actions/yarn-install-and-build + with: + cache_id: sdk-auction-house + working_dir: ./auction-house/cli + build_auction_house_cli: true + # Run integration test - name: start-local-test-validator working-directory: ./auction-house/js diff --git a/auction-house/cli/package.json b/auction-house/cli/package.json index 411e9b8739..036a257cf5 100644 --- a/auction-house/cli/package.json +++ b/auction-house/cli/package.json @@ -9,7 +9,8 @@ "format:check": "prettier --loglevel warn --check \"**/*.{ts,js,json,yaml}\"", "lint:eslint": "eslint '{src,test}/**/*.{ts,tsx}'", "lint:fix": "prettier --write '{src,test}/**/*.{ts,tsx}' && eslint --fix '{src,test}/**/*.{ts,tsx}'", - "test": "jest" + "test": "jest", + "build": "yarn tsc -p ./src" }, "pkg": { "scripts": "./build/**/*.{js|json}" From 3e4cdb1a0fc319aeeb990f6e2654b7c6c21bce69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Flak?= Date: Thu, 11 Aug 2022 22:31:10 +0200 Subject: [PATCH 45/48] trigger --- .github/workflows/integration-auction-house.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/integration-auction-house.yml b/.github/workflows/integration-auction-house.yml index 499df83dfc..577aa676ef 100644 --- a/.github/workflows/integration-auction-house.yml +++ b/.github/workflows/integration-auction-house.yml @@ -101,3 +101,4 @@ jobs: - name: stop-local-test-validator working-directory: ./auction-house/js run: DEBUG=amman* yarn amman:stop + From 835ada4a0a656d54918263cf9c7dd56e985d6158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Flak?= Date: Fri, 19 Aug 2022 18:20:22 +0200 Subject: [PATCH 46/48] lockfile --- yarn.lock | 108 +++++++++++++++--------------------------------------- 1 file changed, 29 insertions(+), 79 deletions(-) diff --git a/yarn.lock b/yarn.lock index 04a571f4e1..278d109721 100644 --- a/yarn.lock +++ b/yarn.lock @@ -952,7 +952,7 @@ __metadata: languageName: node linkType: hard -"@metaplex-foundation/amman@npm:0.10.0": +"@metaplex-foundation/amman@npm:0.10.0, @metaplex-foundation/amman@npm:^0.10.0": version: 0.10.0 resolution: "@metaplex-foundation/amman@npm:0.10.0" dependencies: @@ -998,34 +998,6 @@ __metadata: languageName: node linkType: hard -"@metaplex-foundation/amman@npm:^0.10.0": - version: 0.10.0 - resolution: "@metaplex-foundation/amman@npm:0.10.0" - dependencies: - "@metaplex-foundation/amman-client": ^0.1.0 - "@solana/spl-token": ^0.2.0 - "@solana/web3.js": ^1.43.4 - ansi-colors: ^4.1.1 - bn.js: ^5.2.0 - buffer-hexdump: ^1.0.0 - date-fns: ^2.28.0 - debug: ^4.3.3 - deep-diff: ^1.0.2 - diff: ^5.1.0 - numeral: ^2.0.6 - port-pid: ^0.0.7 - socket.io: ^4.4.1 - split2: ^4.1.0 - text-table: ^0.2.0 - timeago.js: ^4.0.2 - wait-on: ^6.0.0 - yargs: ^17.3.0 - bin: - amman: dist/cli/amman.js - checksum: ceefa1f6db040ceb8b0c423e46bbc1a28881e108c5b7bc6af1fd57315ba173d71d66605c94231cde08382b59dd3b02a3ecfda1835ab4dc1ad3186228a6fc8576 - languageName: node - linkType: hard - "@metaplex-foundation/beet-solana@npm:^0.1.1": version: 0.1.1 resolution: "@metaplex-foundation/beet-solana@npm:0.1.1" @@ -1903,7 +1875,7 @@ __metadata: languageName: node linkType: hard -"@solana/web3.js@npm:^1.17.0, @solana/web3.js@npm:^1.21.0, @solana/web3.js@npm:^1.31.0, @solana/web3.js@npm:^1.32.0, @solana/web3.js@npm:^1.35.0, @solana/web3.js@npm:^1.35.1, @solana/web3.js@npm:^1.36.0, @solana/web3.js@npm:^1.37.0, @solana/web3.js@npm:^1.43.4, @solana/web3.js@npm:^1.44.0, @solana/web3.js@npm:^1.50.1": +"@solana/web3.js@npm:^1.17.0, @solana/web3.js@npm:^1.21.0, @solana/web3.js@npm:^1.31.0, @solana/web3.js@npm:^1.32.0, @solana/web3.js@npm:^1.35.0, @solana/web3.js@npm:^1.35.1, @solana/web3.js@npm:^1.36.0, @solana/web3.js@npm:^1.37.0, @solana/web3.js@npm:^1.44.0, @solana/web3.js@npm:^1.50.1": version: 1.52.0 resolution: "@solana/web3.js@npm:1.52.0" dependencies: @@ -1928,31 +1900,6 @@ __metadata: languageName: node linkType: hard -"@sorend-solana/gummyroll@npm:^0.0.6": - version: 0.0.6 - resolution: "@sorend-solana/gummyroll@npm:0.0.6" - dependencies: - "@metaplex-foundation/beet": ^0.4.0 - "@metaplex-foundation/beet-solana": ^0.3.0 - "@project-serum/anchor": 0.24.2 - "@solana/web3.js": ^1.50.1 - "@sorend-solana/utils": ^0.0.5 - checksum: 2d0539bd002ec9704f5441c8cdd3dd823e45f5063e8a1c0bfcac9a73d4bd86fb88175e1464c928745549e6e22770043cd7831da74a4f6204edd5b3c0b5cf7269 - languageName: node - linkType: hard - -"@sorend-solana/utils@npm:^0.0.5": - version: 0.0.5 - resolution: "@sorend-solana/utils@npm:0.0.5" - dependencies: - "@metaplex-foundation/beet": 0.3.0 - "@project-serum/anchor": 0.24.2 - "@solana/web3.js": ^1.50.1 - borsh: ^0.7.0 - checksum: 5d304ca1ddb69e599d40ca7b38c2fc6761ebd431022b5af705ce9a83404fb44849aa4eff77bec72e655dad833d100c1c24d06c511c0c3edb173136ca42ff83b6 - languageName: node - linkType: hard - "@solana/web3.js@npm:^1.43.4": version: 1.50.1 resolution: "@solana/web3.js@npm:1.50.1" @@ -1978,6 +1925,31 @@ __metadata: languageName: node linkType: hard +"@sorend-solana/gummyroll@npm:^0.0.6": + version: 0.0.6 + resolution: "@sorend-solana/gummyroll@npm:0.0.6" + dependencies: + "@metaplex-foundation/beet": ^0.4.0 + "@metaplex-foundation/beet-solana": ^0.3.0 + "@project-serum/anchor": 0.24.2 + "@solana/web3.js": ^1.50.1 + "@sorend-solana/utils": ^0.0.5 + checksum: 2d0539bd002ec9704f5441c8cdd3dd823e45f5063e8a1c0bfcac9a73d4bd86fb88175e1464c928745549e6e22770043cd7831da74a4f6204edd5b3c0b5cf7269 + languageName: node + linkType: hard + +"@sorend-solana/utils@npm:^0.0.5": + version: 0.0.5 + resolution: "@sorend-solana/utils@npm:0.0.5" + dependencies: + "@metaplex-foundation/beet": 0.3.0 + "@project-serum/anchor": 0.24.2 + "@solana/web3.js": ^1.50.1 + borsh: ^0.7.0 + checksum: 5d304ca1ddb69e599d40ca7b38c2fc6761ebd431022b5af705ce9a83404fb44849aa4eff77bec72e655dad833d100c1c24d06c511c0c3edb173136ca42ff83b6 + languageName: node + linkType: hard + "@tootallnate/once@npm:1": version: 1.1.2 resolution: "@tootallnate/once@npm:1.1.2" @@ -2098,7 +2070,7 @@ __metadata: languageName: node linkType: hard -"@types/node@npm:*, @types/node@npm:>=10.0.0": +"@types/node@npm:*": version: 18.7.2 resolution: "@types/node@npm:18.7.2" checksum: 422cf95dea09959d0e809d24280b76948f60ea805e20d38f07bf9eeafeb413513b9cc365404766f7752bef9cafb8301a882d9d097f780e13f2bedf507459ebc5 @@ -9075,7 +9047,7 @@ __metadata: languageName: node linkType: hard -"tweetnacl@npm:^1.0.3": +"tweetnacl@npm:^1.0.0, tweetnacl@npm:^1.0.3": version: 1.0.3 resolution: "tweetnacl@npm:1.0.3" checksum: e4a57cac188f0c53f24c7a33279e223618a2bfb5fea426231991652a13247bea06b081fd745d71291fcae0f4428d29beba1b984b1f1ce6f66b06a6d1ab90645c @@ -9723,28 +9695,6 @@ __metadata: languageName: node linkType: hard -"ws@npm:~8.2.3": - version: 8.2.3 - resolution: "ws@npm:8.2.3" - peerDependencies: - bufferutil: ^4.0.1 - utf-8-validate: ^5.0.2 - peerDependenciesMeta: - bufferutil: - optional: true - utf-8-validate: - optional: true - checksum: c869296ccb45f218ac6d32f8f614cd85b50a21fd434caf11646008eef92173be53490810c5c23aea31bc527902261fbfd7b062197eea341b26128d4be56a85e4 - languageName: node - linkType: hard - -"xmlhttprequest-ssl@npm:~2.0.0": - version: 2.0.0 - resolution: "xmlhttprequest-ssl@npm:2.0.0" - checksum: 1e98df67f004fec15754392a131343ea92e6ab5ac4d77e842378c5c4e4fd5b6a9134b169d96842cc19422d77b1606b8df84a5685562b3b698cb68441636f827e - languageName: node - linkType: hard - "xtend@npm:~4.0.1": version: 4.0.2 resolution: "xtend@npm:4.0.2" From 7e6ad8677effafe69785932b6e22be72e36a1b68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Flak?= Date: Thu, 25 Aug 2022 20:19:10 +0200 Subject: [PATCH 47/48] Yarn lock after merge --- Cargo.lock | 18 ++++++++++++------ yarn.lock | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 59 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 83cdfc88ca..7a43580305 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1834,7 +1834,7 @@ dependencies = [ "num-traits", "num_enum", "rand 0.8.4", - "shank 0.0.6", + "shank 0.0.8", "solana-program", "solana-program-test", "solana-sdk", @@ -2780,9 +2780,11 @@ dependencies = [ [[package]] name = "shank" -version = "0.0.6" +version = "0.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2935c06d5a141ad2854622a014e30c5eeaa40096667df6bdd682dba9f8f81819" dependencies = [ - "shank_macro 0.0.6", + "shank_macro 0.0.8", ] [[package]] @@ -2799,11 +2801,13 @@ dependencies = [ [[package]] name = "shank_macro" -version = "0.0.6" +version = "0.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ab8a1eb550845e36c88007f4c00175eeeb436d2fc6c70d05207a338cba7519f" dependencies = [ "proc-macro2 1.0.36", "quote 1.0.15", - "shank_macro_impl 0.0.6", + "shank_macro_impl 0.0.8", "syn 1.0.86", ] @@ -2822,7 +2826,9 @@ dependencies = [ [[package]] name = "shank_macro_impl" -version = "0.0.6" +version = "0.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23ec51b35f2336faaeff44daf8952ddee4fe3e3693a313804ae7366f18a9967d" dependencies = [ "anyhow", "proc-macro2 1.0.36", diff --git a/yarn.lock b/yarn.lock index af0a28fbdb..b646d9742e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1064,6 +1064,17 @@ __metadata: languageName: node linkType: hard +"@metaplex-foundation/beet@npm:^0.6.0": + version: 0.6.0 + resolution: "@metaplex-foundation/beet@npm:0.6.0" + dependencies: + ansicolors: ^0.3.2 + bn.js: ^5.2.0 + debug: ^4.3.3 + checksum: 33329dbcb86e1a88ae3f325917ea8971fa3b9a5568124a8585b31b092035acaacb8658a6a22c6f8a097b3a2e82c721ee2ade30aa3e6f1ada141db353ad86a772 + languageName: node + linkType: hard + "@metaplex-foundation/cusper@npm:^0.0.2": version: 0.0.2 resolution: "@metaplex-foundation/cusper@npm:0.0.2" @@ -1283,6 +1294,21 @@ __metadata: languageName: unknown linkType: soft +"@metaplex-foundation/mpl-nft-packs@workspace:nft-packs/js": + version: 0.0.0-use.local + resolution: "@metaplex-foundation/mpl-nft-packs@workspace:nft-packs/js" + dependencies: + "@metaplex-foundation/beet": ^0.6.0 + "@metaplex-foundation/beet-solana": ^0.3.0 + "@metaplex-foundation/cusper": ^0.0.2 + "@metaplex-foundation/solita": ^0.13.0 + "@solana/web3.js": ^1.35.1 + eslint: ^8.3.0 + rimraf: ^3.0.2 + typescript: ^4.6.2 + languageName: unknown + linkType: soft + "@metaplex-foundation/mpl-token-entangler@workspace:token-entangler/js": version: 0.0.0-use.local resolution: "@metaplex-foundation/mpl-token-entangler@workspace:token-entangler/js" @@ -1408,6 +1434,26 @@ __metadata: languageName: node linkType: hard +"@metaplex-foundation/solita@npm:^0.13.0": + version: 0.13.0 + resolution: "@metaplex-foundation/solita@npm:0.13.0" + dependencies: + "@metaplex-foundation/beet": ^0.6.0 + "@metaplex-foundation/beet-solana": ^0.3.0 + "@metaplex-foundation/rustbin": ^0.3.0 + "@solana/web3.js": ^1.36.0 + camelcase: ^6.2.1 + debug: ^4.3.3 + js-sha256: ^0.9.0 + prettier: ^2.5.1 + snake-case: ^3.0.4 + spok: ^1.4.3 + bin: + solita: dist/src/cli/solita.js + checksum: 4e6e9e2cbcb1fc944a1f0e48616b1bce428920effa2db8bc49a80f929d197dfc487e4b65891ccb7804b504ac12e7f01a431da3d520ef55b2b175e05a2ec97ac4 + languageName: node + linkType: hard + "@metaplex-foundation/solita@npm:^0.2.0": version: 0.2.1 resolution: "@metaplex-foundation/solita@npm:0.2.1" @@ -9047,7 +9093,7 @@ __metadata: languageName: node linkType: hard -"tweetnacl@npm:^1.0.3": +"tweetnacl@npm:^1.0.0, tweetnacl@npm:^1.0.3": version: 1.0.3 resolution: "tweetnacl@npm:1.0.3" checksum: e4a57cac188f0c53f24c7a33279e223618a2bfb5fea426231991652a13247bea06b081fd745d71291fcae0f4428d29beba1b984b1f1ce6f66b06a6d1ab90645c From a7087cadb9a3e5963713fe7b618398d07fb9dfe1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Flak?= Date: Thu, 25 Aug 2022 20:34:48 +0200 Subject: [PATCH 48/48] prettier --- .../js/test/account-instructions.auction-house.test.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/auction-house/js/test/account-instructions.auction-house.test.ts b/auction-house/js/test/account-instructions.auction-house.test.ts index 00c66a4a5c..0734bd6e9d 100644 --- a/auction-house/js/test/account-instructions.auction-house.test.ts +++ b/auction-house/js/test/account-instructions.auction-house.test.ts @@ -167,13 +167,9 @@ test('test auction-house instructions', async (t) => { const deposit_instruction = createDepositInstruction(depositAccounts, deposit_args); const deposit_tx = new Transaction().add(deposit_instruction); deposit_tx.recentBlockhash = (await connection.getRecentBlockhash()).blockhash; - await transactionHandler.sendAndConfirmTransaction( - deposit_tx, - [wallet, authority], - { - skipPreflight: false, - }, - ); + await transactionHandler.sendAndConfirmTransaction(deposit_tx, [wallet, authority], { + skipPreflight: false, + }); const deposit_fee_paid = (await connection.getFeeForMessage(deposit_tx.compileMessage())).value; const wallet_sol_post_deposit_balance = await connection.getBalance(wallet.publicKey);