diff --git a/prototype/.env.exemple b/prototype/.env.exemple index 32494407..9436d2a5 100644 --- a/prototype/.env.exemple +++ b/prototype/.env.exemple @@ -25,3 +25,4 @@ DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:$ NOSTR_RELAYER_WEBSOCKET=ws://localhost:3000 ESCROW_CLASS_HASH=0x3f70abaaeef59cc900b597d45a2c97c08abb5260c03327cce9e45d4c7a8ad0 # Sepolia +REDECLARE_ACCOUNT=false # Set to true on devnet \ No newline at end of file diff --git a/prototype/constants/index.ts b/prototype/constants/index.ts index a2a3cc94..13b7ee4d 100644 --- a/prototype/constants/index.ts +++ b/prototype/constants/index.ts @@ -23,8 +23,9 @@ export const ACCOUNT_TEST_PROFILE = { "0x1b5f5bee60ce25d6979c5b88cfbb74ad1dae197dba11719b2e06a5efa7e666d", }, escrow: { - contract: "0x53327953bddcb4ae216b14ea0b84261c6c1ad0af112a29be2dab11cf2e76c48", - SEPOLIA: "0x53327953bddcb4ae216b14ea0b84261c6c1ad0af112a29be2dab11cf2e76c48" + contract:"0x2d8281937c8f815a53ae4d02252154b225f87973ec96d3f08bdd624bf6e685d" + // contract: "0x53327953bddcb4ae216b14ea0b84261c6c1ad0af112a29be2dab11cf2e76c48", + // SEPOLIA: "0x53327953bddcb4ae216b14ea0b84261c6c1ad0af112a29be2dab11cf2e76c48" } }; export const ERROR_MESSAGES = { diff --git a/prototype/test/escrow.test.ts b/prototype/test/escrow.test.ts index 04b30de0..13704142 100644 --- a/prototype/test/escrow.test.ts +++ b/prototype/test/escrow.test.ts @@ -22,9 +22,11 @@ dotenv.config(); */ // Sepolia params testing const currentId = 1 +// const idToClaim = 1 const idToClaim = 1 + const idToCancel = 1 -let escrow_address = ACCOUNT_TEST_PROFILE.escrow.contract // change default address +let escrow_address:string|undefined = ACCOUNT_TEST_PROFILE.escrow.contract // change default address let token_used_address = TOKENS_ADDRESS.DEVNET.ETH; describe("Escrow End to end test", () => { @@ -38,6 +40,10 @@ describe("Escrow End to end test", () => { let escrowContract = await createEscrowAccount(); console.log("escrow address", escrowContract?.contract_address) + + if(escrowContract?.contract_address) { + escrow_address=escrowContract?.contract_address + } escrow = await prepareAndConnectContract( escrowContract?.contract_address ?? ACCOUNT_TEST_PROFILE?.escrow?.contract, // uncomment if you recreate a contract account @@ -57,20 +63,10 @@ describe("Escrow End to end test", () => { const account = new Account(provider, accountAddress0, privateKey0, "1"); const alicePublicKey = ACCOUNT_TEST_PROFILE?.alice?.nostrPublicKey; - let escrow; - if (process.env.IS_DEPLOY_CONTRACT == "true") { - let escrowContract = await createEscrowAccount(); - - escrow = await prepareAndConnectContract( - escrowContract?.contract_address ?? ACCOUNT_TEST_PROFILE?.escrow?.contract, // uncomment if you recreate a contract - account - ); - } else { - escrow = await prepareAndConnectContract( - escrow_address ?? ACCOUNT_TEST_PROFILE?.escrow?.contract, - account - ); - } + let escrow = await prepareAndConnectContract( + escrow_address ?? ACCOUNT_TEST_PROFILE?.escrow?.contract, + account + ); /** Send a note */ let amount: number = 1; @@ -131,9 +127,13 @@ describe("Escrow End to end test", () => { } /** Claim */ let timestamp = 1716285235; + + + let depositToClaim = await escrow.get_deposit(idToClaim) + console.log("deposit to claim",depositToClaim) // let timestamp = new Date().getTime(); - let content = `claim ${cairo.felt(currentId)}`; + let content = `claim ${cairo.felt(idToClaim)}`; let txClaim = await claimDeposit({ escrow, account, diff --git a/prototype/utils/escrow.ts b/prototype/utils/escrow.ts index 029d894d..1f59186d 100644 --- a/prototype/utils/escrow.ts +++ b/prototype/utils/escrow.ts @@ -67,19 +67,21 @@ export const createEscrowAccount = async () => { // const AAaccount = new Account(provider, AAcontractAddress, AAprivateKey); /** @description uncomment this to declare your account */ // console.log("declare account"); - console.log("try declare account"); - const declareResponse = await account0.declare({ - contract: compiledSierraAAaccount, - casm: compiledAACasm, - }); - console.log("Declare deploy", declareResponse?.transaction_hash); - await provider.waitForTransaction(declareResponse?.transaction_hash); - const contractClassHash = declareResponse.class_hash; - EscrowClassHash = contractClassHash; - - const nonce = await account0?.getNonce(); - console.log("nonce", nonce); + if(process.env.REDECLARE_ACCOUNT) { + console.log("try declare account"); + const declareResponse = await account0.declare({ + contract: compiledSierraAAaccount, + casm: compiledAACasm, + }); + console.log("Declare deploy", declareResponse?.transaction_hash); + await provider.waitForTransaction(declareResponse?.transaction_hash); + const contractClassHash = declareResponse.class_hash; + EscrowClassHash = contractClassHash; + + const nonce = await account0?.getNonce(); + console.log("nonce", nonce); + } const { transaction_hash, contract_address } = await account0.deployContract({