-
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.
Add scripts for creating and claiming gifts
- Loading branch information
Showing
7 changed files
with
176 additions
and
59 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
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
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
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 { constants, RpcProvider } from "starknet"; | ||
import { claimInternal } from "../lib"; | ||
|
||
/// To use this script, fill in the following 3 variables printed from scripts/create_gift.ts: | ||
|
||
const gift = { | ||
factory: "0x000000000000000000000000000000000000000000000000000000000000000", | ||
escrow_class_hash: "0x000000000000000000000000000000000000000000000000000000000000000", | ||
sender: "0x0000000000000000000000000000000000000000000000000000000000000000", | ||
gift_token: "0x0000000000000000000000000000000000000000000000000000000000000000", | ||
gift_amount: 69n, | ||
fee_token: "0x0000000000000000000000000000000000000000000000000000000000000000", | ||
fee_amount: 42n, | ||
gift_pubkey: 100000000000000000000000000000000000000000000000000000000000000000000000000n, | ||
} ; | ||
const receiver = "0x0000000000000000000000000000000000000000000000000000000000000000"; | ||
const giftPrivateKey = "0x0000000000000000000000000000000000000000000000000000000000000000"; | ||
|
||
const provider = new RpcProvider({ nodeUrl: constants.NetworkName.SN_SEPOLIA }); | ||
const receipt = await claimInternal({ gift, receiver, giftPrivateKey, provider }); | ||
|
||
console.log("Tx hash:", receipt.transaction_hash); |
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,36 @@ | ||
import { createDeposit, LegacyStarknetKeyPair } from "../lib"; | ||
import { logTransactionJson } from "./json_tx_builder"; | ||
|
||
/// To use this script, check the following value: | ||
|
||
const factoryAddress = "0x42a18d85a621332f749947a96342ba682f08e499b9f1364325903a37c5def60"; | ||
const escrowAccountClassHash = "0x661aad3c9812f0dc0a78f320a58bdd8fed18ef601245c20e4bf43667bfd0289"; | ||
const ethAddress = "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"; | ||
const strkAddress = "0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d"; | ||
|
||
if (!factoryAddress) { | ||
throw new Error("Factory contract address is not set. Please set it in the script file."); | ||
} | ||
|
||
const giftSigner = new LegacyStarknetKeyPair(); | ||
const sender = "0x1111111111111111111111111111111111111111111111111111111111111111"; | ||
const receiver = "0x2222222222222222222222222222222222222222222222222222222222222222"; | ||
|
||
const { calls, gift } = createDeposit(sender, { | ||
giftAmount: 1n, // 1 wei | ||
feeAmount: 3n * 10n ** 18n, // 3 STRK | ||
factoryAddress, | ||
feeTokenAddress: strkAddress, | ||
giftTokenAddress: ethAddress, | ||
giftSignerPubKey: giftSigner.publicKey, | ||
escrowAccountClassHash, | ||
}); | ||
|
||
console.log(); | ||
console.log("const gift =", gift, ";"); | ||
console.log(`const receiver = "${receiver}";`); | ||
console.log(`const giftPrivateKey = "${giftSigner.privateKey}";`); | ||
console.log(); | ||
|
||
console.log("Calls:"); | ||
logTransactionJson(calls); |
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