diff --git a/scripts/cancel_upgrade.ts b/scripts/cancel_upgrade.ts new file mode 100644 index 0000000..034eda8 --- /dev/null +++ b/scripts/cancel_upgrade.ts @@ -0,0 +1,18 @@ +import { logTransactionJson } from "./json_tx_builder"; + +/// To use this script, fill in the following value: +/// - factoryAddress: the address of the factory contract + +const factoryAddress = ""; + +if (!factoryAddress) { + throw new Error("Factory contract address is not set. Please set it in the script file."); +} + +const tx = { + contractAddress: factoryAddress, + entrypoint: "cancel_upgrade", + calldata: [], +}; + +logTransactionJson([tx]); diff --git a/scripts/claim_dust.ts b/scripts/claim_dust.ts new file mode 100644 index 0000000..6b2fb73 --- /dev/null +++ b/scripts/claim_dust.ts @@ -0,0 +1,43 @@ +import { CallData } from "starknet"; +import { calculateEscrowAddress } from "../lib"; +import { Gift, buildGiftCallData, executeActionOnAccount } from "../lib/claim"; +import { logTransactionJson } from "./json_tx_builder"; + +/// To use this script, fill in the following value: +/// - factoryAddress: the address of the factory contract +/// - dustReceiver: the address of the dust receiver +/// - claim: the claim object + +const factoryAddress = ""; +const dustReceiver = ""; +const claim: Gift = { + factory: factoryAddress, + escrow_class_hash: "", + sender: "", + gift_token: "", + gift_amount: 0n, + fee_token: "", + fee_amount: 0n, + gift_pubkey: 0n, +}; + +if (!factoryAddress) { + throw new Error("Factory contract address is not set. Please set it in the script file."); +} + +if (!dustReceiver) { + throw new Error("Dust receiver address is not set. Please set it in the script file."); +} + +for (const key in claim) { + if (key in claim && !claim[key as keyof typeof claim] && key !== "fee_amount" && key !== "gift_amount") { + throw new Error(`The property ${key} is empty in the claim object.`); + } +} + +const tx = executeActionOnAccount( + "claim_dust", + calculateEscrowAddress(claim), + CallData.compile([(buildGiftCallData(claim), dustReceiver)]), +); +logTransactionJson([tx]); diff --git a/scripts/json_tx_builder.ts b/scripts/json_tx_builder.ts new file mode 100644 index 0000000..31f2b8d --- /dev/null +++ b/scripts/json_tx_builder.ts @@ -0,0 +1,5 @@ +import { Call } from "starknet"; + +export function logTransactionJson(transaction: Call[]) { + console.log(JSON.stringify(transaction, null, 2)); +} diff --git a/scripts/pause.ts b/scripts/pause.ts new file mode 100644 index 0000000..c7c1889 --- /dev/null +++ b/scripts/pause.ts @@ -0,0 +1,18 @@ +import { logTransactionJson } from "./json_tx_builder"; + +/// To use this script, fill in the following value: +/// - factoryAddress: the address of the factory contract + +const factoryAddress = ""; + +if (!factoryAddress) { + throw new Error("Factory contract address is not set. Please set it in the script file."); +} + +const tx = { + contractAddress: factoryAddress, + entrypoint: "pause", + calldata: [], +}; + +logTransactionJson([tx]); diff --git a/scripts/propose_upgrade.ts b/scripts/propose_upgrade.ts new file mode 100644 index 0000000..49e64bf --- /dev/null +++ b/scripts/propose_upgrade.ts @@ -0,0 +1,33 @@ +import { CallData } from "starknet"; +import { logTransactionJson } from "./json_tx_builder"; + +/// To use this script, fill in the following value: +/// - factoryAddress: the address of the factory contract +/// - newImplementation: the class ahs of the new implementation contract +/// - callData: the call data for the propose_upgrade function + +const factoryAddress = ""; +const newImplementation = ""; +const callData: any[] = []; + +if (!factoryAddress) { + throw new Error("Factory contract address is not set. Please set it in the script file."); +} + +if (!newImplementation) { + throw new Error("New implementation class hash is not set. Please set it in the script file."); +} + +const tx = { + contractAddress: factoryAddress, + entrypoint: "propose_upgrade", + calldata: CallData.compile([newImplementation, callData]), +}; + +// date 7 days from now +const date = new Date(); +date.setDate(date.getDate() + 7); + +logTransactionJson([tx]); + +console.log("Proposed upgrade will be ready at: ", date); diff --git a/scripts/unpause.ts b/scripts/unpause.ts new file mode 100644 index 0000000..3c64e00 --- /dev/null +++ b/scripts/unpause.ts @@ -0,0 +1,18 @@ +import { logTransactionJson } from "./json_tx_builder"; + +/// To use this script, fill in the following value: +/// - factoryAddress: the address of the factory contract + +const factoryAddress = ""; + +if (!factoryAddress) { + throw new Error("Factory contract address is not set. Please set it in the script file."); +} + +const tx = { + contractAddress: factoryAddress, + entrypoint: "unpause", + calldata: [], +}; + +logTransactionJson([tx]); diff --git a/scripts/upgrade.ts b/scripts/upgrade.ts new file mode 100644 index 0000000..9168a60 --- /dev/null +++ b/scripts/upgrade.ts @@ -0,0 +1,22 @@ +import { CallData } from "starknet"; +import { logTransactionJson } from "./json_tx_builder"; + +/// To use this script, fill in the following value: +/// - factoryAddress: the address of the factory contract +/// - callData: upgrade call data + +const factoryAddress = ""; + +const callData: any[] = []; + +if (!factoryAddress) { + throw new Error("Factory contract address is not set. Please set it in the script file."); +} + +const tx = { + contractAddress: factoryAddress, + entrypoint: "upgrade", + calldata: CallData.compile(callData), +}; + +logTransactionJson([tx]);