Skip to content

Commit

Permalink
fix contract address since should be used with instantiate
Browse files Browse the repository at this point in the history
  • Loading branch information
ltfschoen committed Oct 6, 2024
1 parent d6ab7dd commit 31fbcfd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/secret-upload-contract/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ async function main () {

let codeId: String | undefined;
let contractCodeHash: String | undefined;
let contractAddress;

let tx = await secretjs.tx.compute.storeCode(
{
Expand Down Expand Up @@ -92,6 +91,8 @@ async function main () {
};

let instantiate_contract = async (params: CODE_PARAMS) => {
let contractAddress;

if (!params.codeId || !params.contractCodeHash) {
throw new Error("codeId or contractCodeHash is not set.");
}
Expand All @@ -116,11 +117,13 @@ async function main () {
);

//Find the contract_address in the logs
const contractAddress = tx?.arrayLog?.find(
contractAddress = tx?.arrayLog?.find(
(log) => log?.type === "message" && log?.key === "contract_address"
)?.value;

console.log("SECRET_ADDRESS: ", contractAddress);

return contractAddress;
};

// Chain the execution using promises
Expand Down

0 comments on commit 31fbcfd

Please sign in to comment.