-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from argentlabs/feat/admin-scripts
Scripts for admin functionality
- Loading branch information
Showing
7 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Call } from "starknet"; | ||
|
||
export function logTransactionJson(transaction: Call[]) { | ||
console.log(JSON.stringify(transaction, null, 2)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]); |