diff --git a/.DS_Store b/.DS_Store index 02a084f..5008ddf 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/scripts/cep78/approve.ts b/scripts/cep78/approve.ts index 87d7e08..3e7c969 100644 --- a/scripts/cep78/approve.ts +++ b/scripts/cep78/approve.ts @@ -5,6 +5,8 @@ import { Keys, CLString, CLU64, + CLKey, + CLByteArray, } from "casper-js-sdk"; import { stringToKey } from "./utils"; import dotenv from "dotenv"; @@ -14,9 +16,9 @@ dotenv.config(); let rpcUri: string; let privateKey: string; -if (process.env.RPC_URI && process.env.PRIIVATE_KEY) { +if (process.env.RPC_URI && process.env.PRIVATE_KEY) { rpcUri = process.env.RPC_URI; - privateKey = process.env.PRIIVATE_KEY; + privateKey = process.env.PRIVATE_KEY; } else { throw new Error(`No rpcUri or privateKey found`); } @@ -25,8 +27,10 @@ const casperClient = new CasperClient(rpcUri); const privateKeyPath = "/Users/bufo/Downloads/BitHotel_secret_key.pem"; +// 0165e406c81af68793a4f56b60f646f9eeba2fad1bd16f06cd1c42f6f8d88cc5fb const key = Keys.Ed25519.loadKeyPairFromPrivateFile(privateKeyPath); +// 013cafb1912c0ca0dc6e0251905f29ebe01176371c298e513a24c0f2d9b2bbff28 const key2 = Keys.getKeysFromHexPrivKey( privateKey, Keys.SignatureAlgorithm.Ed25519 @@ -34,14 +38,21 @@ const key2 = Keys.getKeysFromHexPrivKey( const contractClient = new Contracts.Contract(); contractClient.setContractHash( - "hash-0b659298a70a7bfcde35aceb49a0d7b4a34aed5e0a7e946db135d598edd411b9" + "hash-59a13d7a9c89d989a13b9b15e183eb0ab695b95c98fd98a082b171efacd1c3ca" ); const runtimeArgs = RuntimeArgs.fromMap({ - operator: stringToKey( - "cc8d74f5cdd36bf926ebb47f57f6d6f2317846c852623fcee72bb5f756d99857" + operator: new CLKey( + new CLByteArray( + Uint8Array.from( + Buffer.from( + "411f0c5ae537b18beabfe43601d3e2d238bd7b89e1566ff78fff66a07826a0db", + "hex" + ) + ) + ) ), - token_id: new CLU64(2), + token_id: new CLU64(9), }); const preparedDeploy = contractClient.callEntrypoint( diff --git a/scripts/cep78/mint.ts b/scripts/cep78/mint.ts index 246193a..b133857 100644 --- a/scripts/cep78/mint.ts +++ b/scripts/cep78/mint.ts @@ -17,9 +17,9 @@ dotenv.config(); let rpcUri: string; let privateKey: string; -if (process.env.RPC_URI && process.env.PRIIVATE_KEY) { +if (process.env.RPC_URI && process.env.PRIVATE_KEY) { rpcUri = process.env.RPC_URI; - privateKey = process.env.PRIIVATE_KEY; + privateKey = process.env.PRIVATE_KEY; } else { throw new Error(`No rpcUri or privateKey found`); } @@ -28,7 +28,10 @@ const casperClient = new CasperClient(rpcUri); const privateKeyPath = "/Users/bufo/Downloads/BitHotel_secret_key.pem"; +// 0165e406c81af68793a4f56b60f646f9eeba2fad1bd16f06cd1c42f6f8d88cc5fb const key = Keys.Ed25519.loadKeyPairFromPrivateFile(privateKeyPath); + +// 013cafb1912c0ca0dc6e0251905f29ebe01176371c298e513a24c0f2d9b2bbff28 const recipientKey = Keys.getKeysFromHexPrivKey( privateKey, Keys.SignatureAlgorithm.Ed25519 @@ -36,33 +39,25 @@ const recipientKey = Keys.getKeysFromHexPrivKey( const contractClient = new Contracts.Contract(); contractClient.setContractHash( - "hash-0b659298a70a7bfcde35aceb49a0d7b4a34aed5e0a7e946db135d598edd411b9" + "hash-59a13d7a9c89d989a13b9b15e183eb0ab695b95c98fd98a082b171efacd1c3ca" ); const metadata = { - name: "Casper punk", - description: "This is a Casper Punk!", + name: "CasperPunk Hotel Guest", + description: + "The original and limited edition CasperPunk hotel guest that is only available on the Casper blockchain. This scary character is in high demand among hotel guests.", image: - "https://apigateway.bithotel.io/metadata/QmWN9Gb4A1gT1j7DQj34gn3Mta3jQcsLmddjaU7JabcHuG", - external_link: "https://bithotel.io/#/", + "https://apigateway.bithotel.io/metadata/QmSFjb5DtAg5Zyf6fvferRCGijUfLUmMV1jTYCX7k1uTRG", + external_link: "https://www.bithotel.io/#/", attributes: [ - { - trait_type: "Rarity", - value: "Epic", - }, - { - trait_type: "Replicas", - value: "10", - }, - { - trait_type: "Drop", - value: "Season 2", - }, + { trait_type: "Rarity", value: "Uncommon" }, + { trait_type: "Replicas", value: "3000" }, + { trait_type: "Drop", value: "Season 2" }, ], }; const runtimeArgs = RuntimeArgs.fromMap({ - token_owner: new CLKey(recipientKey.publicKey), + token_owner: new CLKey(key.publicKey), token_meta_data: new CLString(JSON.stringify(metadata)), }); @@ -71,7 +66,7 @@ const preparedDeploy = contractClient.callEntrypoint( runtimeArgs, key.publicKey, "casper-test", - "20000000000", + "5000000000", [key] ); diff --git a/scripts/marketplace/add-listing.ts b/scripts/marketplace/add-listing.ts index 50f1f54..ecb76ab 100644 --- a/scripts/marketplace/add-listing.ts +++ b/scripts/marketplace/add-listing.ts @@ -14,9 +14,9 @@ dotenv.config(); let rpcUri: string; let privateKey: string; -if (process.env.RPC_URI && process.env.PRIIVATE_KEY) { +if (process.env.RPC_URI && process.env.PRIVATE_KEY) { rpcUri = process.env.RPC_URI; - privateKey = process.env.PRIIVATE_KEY; + privateKey = process.env.PRIVATE_KEY; } else { throw new Error(`No rpcUri or privateKey found`); } @@ -26,30 +26,34 @@ const key = Keys.getKeysFromHexPrivKey( privateKey, Keys.SignatureAlgorithm.Ed25519 ); +const privateKeyPath = "/Users/bufo/Downloads/BitHotel_secret_key.pem"; + +const key2 = Keys.Ed25519.loadKeyPairFromPrivateFile(privateKeyPath); + // b590bbf67fb2f60bdb54a7295bbb602f63008e4d8bb49fefe093ec805283b82f // cc8d74f5cdd36bf926ebb47f57f6d6f2317846c852623fcee72bb5f756d99857 const contractClient = new Contracts.Contract(); contractClient.setContractHash( - "hash-cc8d74f5cdd36bf926ebb47f57f6d6f2317846c852623fcee72bb5f756d99857" + "hash-411f0c5ae537b18beabfe43601d3e2d238bd7b89e1566ff78fff66a07826a0db" ); -console.log({ hash: contractClient.contractHash }); +const price = 75; const runtimeArgs = RuntimeArgs.fromMap({ collection: CasperHelpers.stringToKey( - "0b659298a70a7bfcde35aceb49a0d7b4a34aed5e0a7e946db135d598edd411b9" + "59a13d7a9c89d989a13b9b15e183eb0ab695b95c98fd98a082b171efacd1c3ca" ), - token_id: new CLU64(2), - price: new CLU256(50), + token_id: new CLU64(9), + price: new CLU256(price * 1_000_000_000), }); const preparedDeploy = contractClient.callEntrypoint( "add_listing", runtimeArgs, - key.publicKey, + key2.publicKey, "casper-test", - "35000000000", - [key] + "10000000000", + [key2] ); -// casperClient.putDeploy(preparedDeploy).then(console.log).catch(console.error); +casperClient.putDeploy(preparedDeploy).then(console.log).catch(console.error); diff --git a/scripts/marketplace/cancel-listing.ts b/scripts/marketplace/cancel-listing.ts index dc1afcb..fd245bd 100644 --- a/scripts/marketplace/cancel-listing.ts +++ b/scripts/marketplace/cancel-listing.ts @@ -12,9 +12,9 @@ dotenv.config(); let rpcUri: string; let privateKey: string; -if (process.env.RPC_URI && process.env.PRIIVATE_KEY) { +if (process.env.RPC_URI && process.env.PRIVATE_KEY) { rpcUri = process.env.RPC_URI; - privateKey = process.env.PRIIVATE_KEY; + privateKey = process.env.PRIVATE_KEY; } else { throw new Error(`No rpcUri or privateKey found`); } @@ -28,11 +28,11 @@ const key = Keys.getKeysFromHexPrivKey( const contractClient = new Contracts.Contract(); contractClient.setContractHash( - "hash-b590bbf67fb2f60bdb54a7295bbb602f63008e4d8bb49fefe093ec805283b82f" + "hash-411f0c5ae537b18beabfe43601d3e2d238bd7b89e1566ff78fff66a07826a0db" ); const runtimeArgs = RuntimeArgs.fromMap({ - listing_id: new CLU64(3), + listing_id: new CLU64(4), }); const preparedDeploy = contractClient.callEntrypoint( diff --git a/scripts/marketplace/execute-listing.ts b/scripts/marketplace/execute-listing.ts new file mode 100644 index 0000000..0f91bcf --- /dev/null +++ b/scripts/marketplace/execute-listing.ts @@ -0,0 +1,56 @@ +import { + CasperClient, + Contracts, + RuntimeArgs, + Keys, + CLU64, + CLU512, +} from "casper-js-sdk"; +import dotenv from "dotenv"; +import { readFileSync } from "fs"; +import { CasperHelpers } from "./helpers"; + +dotenv.config(); + +let rpcUri: string; +let privateKey: string; + +if (process.env.RPC_URI && process.env.PRIVATE_KEY) { + rpcUri = process.env.RPC_URI; + privateKey = process.env.PRIVATE_KEY; +} else { + throw new Error(`No rpcUri or privateKey found`); +} + +const casperClient = new CasperClient(rpcUri); + +const privateKeyPath = "/Users/bufo/Downloads/BitHotel_secret_key.pem"; + +const key = Keys.Ed25519.loadKeyPairFromPrivateFile(privateKeyPath); + +const executeListingFile = readFileSync("./execute_listing_call.wasm"); + +const wasm = Uint8Array.from(executeListingFile); + +const contractClient = new Contracts.Contract(); + +const price = 27; + +const runtimeArgs = RuntimeArgs.fromMap({ + marketplace_contract_hash: CasperHelpers.stringToKey( + "411f0c5ae537b18beabfe43601d3e2d238bd7b89e1566ff78fff66a07826a0db" + ), + listing_id: new CLU64(16), + amount: new CLU512(price * 1_000_000_000), +}); + +const preparedDeploy = contractClient.install( + wasm, + runtimeArgs, + "15000000000", + key.publicKey, + "casper-test", + [key] +); + +casperClient.putDeploy(preparedDeploy).then(console.log).catch(console.error); diff --git a/scripts/marketplace/execute_listing_call.wasm b/scripts/marketplace/execute_listing_call.wasm new file mode 100755 index 0000000..f9e0205 Binary files /dev/null and b/scripts/marketplace/execute_listing_call.wasm differ diff --git a/scripts/marketplace/package.json b/scripts/marketplace/package.json index 5406522..233286e 100644 --- a/scripts/marketplace/package.json +++ b/scripts/marketplace/package.json @@ -6,5 +6,8 @@ "dependencies": { "casper-js-sdk": "^2.12.1", "dotenv": "^16.0.3" + }, + "devDependencies": { + "fs": "^0.0.1-security" } } diff --git a/scripts/marketplace/whitelist.ts b/scripts/marketplace/whitelist.ts index 950b643..960cc6a 100644 --- a/scripts/marketplace/whitelist.ts +++ b/scripts/marketplace/whitelist.ts @@ -15,9 +15,9 @@ dotenv.config(); let rpcUri: string; let privateKey: string; -if (process.env.RPC_URI && process.env.PRIIVATE_KEY) { +if (process.env.RPC_URI && process.env.PRIVATE_KEY) { rpcUri = process.env.RPC_URI; - privateKey = process.env.PRIIVATE_KEY; + privateKey = process.env.PRIVATE_KEY; } else { throw new Error(`No rpcUri or privateKey found`); } @@ -30,12 +30,12 @@ const key = Keys.Ed25519.loadKeyPairFromPrivateFile(privateKeyPath); const contractClient = new Contracts.Contract(); contractClient.setContractHash( - "hash-cc8d74f5cdd36bf926ebb47f57f6d6f2317846c852623fcee72bb5f756d99857" + "hash-411f0c5ae537b18beabfe43601d3e2d238bd7b89e1566ff78fff66a07826a0db" ); const runtimeArgs = RuntimeArgs.fromMap({ collection: CasperHelpers.stringToKey( - "0b659298a70a7bfcde35aceb49a0d7b4a34aed5e0a7e946db135d598edd411b9" + "59a13d7a9c89d989a13b9b15e183eb0ab695b95c98fd98a082b171efacd1c3ca" ), }); diff --git a/scripts/marketplace/yarn.lock b/scripts/marketplace/yarn.lock index aa3f65b..8507116 100644 --- a/scripts/marketplace/yarn.lock +++ b/scripts/marketplace/yarn.lock @@ -314,6 +314,11 @@ file-uri-to-path@1.0.0: resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd" integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw== +fs@^0.0.1-security: + version "0.0.1-security" + resolved "https://registry.yarnpkg.com/fs/-/fs-0.0.1-security.tgz#8a7bd37186b6dddf3813f23858b57ecaaf5e41d4" + integrity sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w== + hash-base@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/hash-base/-/hash-base-3.1.0.tgz#55c381d9e06e1d2997a883b4a3fddfe7f0d3af33"