Skip to content

Commit

Permalink
Merge pull request #142 from horuslabsio/fix/scripts
Browse files Browse the repository at this point in the history
chore: fix community, add scripts
  • Loading branch information
horusbot authored Jan 17, 2025
2 parents 2058c93 + 83de8a8 commit 8f8cc24
Show file tree
Hide file tree
Showing 11 changed files with 3,126 additions and 10 deletions.
4 changes: 2 additions & 2 deletions addresses.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ SEPOLIA ADDRESSES:
| Community NFT | 0x03081ad7d528fbf2b3bb3954e688fc7339dda70d79029f44005294450a1f5e9b | - |
| Handles | 0x04c627aded2129f87a55e43ed2efb7fc5d9d824fd3dafe8907833e24d104822f | 0x02d365a9e93fb1a87e5b5f8b69091d71b222b1a20873fb40ce956846f4b7048b |
| Handles Registry | 0x06d672a615f4035563f989eb423d563d011ea9c4f932ba0c8fe85f5811567834 | 0x0122223d4da13bd2854b606079cf6016c7e4b20d67236fd740ab1713c43e8919 |
| Coloniz NFT | 0x00ece545a7650d6233077a8cce0d6388c0800c907c7b3dd598369127ff21fc26 | 0x036053a7520d7ff5cb1ce8ebec7acaf8b6364130865662937ab1e2a36d4e00c1 |
| Hub | 0x00134fe5f890dfa427b1975f26f15620b8194f0b64b2beb2bbf5b868b95941d2 | 0x04bd89ef797c5a34a3c8bcc9dafca270959d9edcd568ea22a2364ffb3af959f0 |
| Coloniz NFT | 0x3c41f11a24c53fb5bbc9c1a03626f583ccdd1b0c2215756448cc41b29fc0841 | 0x036053a7520d7ff5cb1ce8ebec7acaf8b6364130865662937ab1e2a36d4e00c1 |
| Hub | 0x419ba8da29d7364aa6638a066b9199e5ec56ba718ae75c9d0ddee60e08aabfb | 0x04bd89ef797c5a34a3c8bcc9dafca270959d9edcd568ea22a2364ffb3af959f0 |
2 changes: 1 addition & 1 deletion scripts/.env.example
Original file line number Diff line number Diff line change
@@ -1 +1 @@
PRIVATE_KEY="9bd7e28ed81dde38ea2be0149868a95e8eed5e770cc2f11f7b8ef636715e24cb"
PRIVATE_KEY=""
2,766 changes: 2,765 additions & 1 deletion scripts/src/abi/hub.json

Large diffs are not rendered by default.

314 changes: 314 additions & 0 deletions scripts/src/contracts/community.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,314 @@
import { Call } from "starknet-tokenbound-sdk";
import { coloniz_HUB_CONTRACT_ADDRESS, PROFILE_ADDRESS_ONE, PROFILE_ADDRESS_TWO } from "../helpers/constants";
import tokenbound from "../index";
import { cairo, CallData,CairoCustomEnum, Uint256 } from "starknet";

import abi from "../abi/hub.json";

export const CommunityType = {
Free: "Free",
Standard: "Standard",
Business:"Business"
} as const;

export const GateKeepType = {
Open: "Open",
NFTGating: "NFTGating",
PermissionedGating: "PermissionedGating",
PaidGating: "PaidGating",
} as const;

const execute_create_community = async() =>{
let call:Call = {
to: coloniz_HUB_CONTRACT_ADDRESS,
selector:"0x8945c258076d05a649eb76dca07fe609b43b360775b41226e3a345e9593ab4",
calldata:[]
}
try {
const Resp = await tokenbound?.execute("0x075a4558a2e9d8b10fdb3d94d51b35312703cc7aae43a1ff95e234512e83783f", [call])
console.log('execution-response=:', Resp);
} catch (error) {
console.log(error)
}
}

const execute_create_channel = async() =>{

// assume this is community_id is 1, since the SDK does not return functionn final return value after execution
// https://github.com/horuslabsio/tokenbound-sdk/blob/develop/src/TokenboundClient.ts#L155

let call:Call = {
to: "0x00a21ac387d13c35370bd5539fd9f7cdcbcdec82a6a18e424a83611379facfa3", //coloniz_HUB_CONTRACT_ADDRESS,
selector:"0x33a3cd19c446a4483d4288f10983bf9316ce813aa8ee81acae99b36fc6022d0",
calldata:["0x1", "0x0"] //calldata:[1, 0] // calldata:["0x1", "0x0"]
}

try {
const create_channel_Resp = await tokenbound?.execute("0x075a4558a2e9d8b10fdb3d94d51b35312703cc7aae43a1ff95e234512e83783f", [call])
console.log('execution-response=:', create_channel_Resp)
} catch (error) {
console.log(error)
}

}

const execute_get_community = async() =>{


let call:Call = {
to: "0x00a21ac387d13c35370bd5539fd9f7cdcbcdec82a6a18e424a83611379facfa3", //coloniz_HUB_CONTRACT_ADDRESS,
selector:"0x20bf8f15f5ae139bc6cb98412fbee613a66d1b0950e1f7406e74903621f8fc5",
calldata:["0x1", "0x00"]
}
try {
const create_channel_Resp = await tokenbound?.execute("0x075a4558a2e9d8b10fdb3d94d51b35312703cc7aae43a1ff95e234512e83783f", [call])
console.log('execution-response=:', create_channel_Resp)
} catch (error) {
console.log(error)
}

}

const execute_join_community = async() =>{
// assume this is community_id is 1, since SDK does not return functionn final return value after execution
// https://github.com/horuslabsio/tokenbound-sdk/blob/develop/src/TokenboundClient.ts#L155

let call:Call = {
to:coloniz_HUB_CONTRACT_ADDRESS,
selector:"0x4520555a219f5c8f5c5dba38600b2ef90052dda2c3bd82d24968e43fb54207",
calldata:["0x1"]
}
try {
const Resp = await tokenbound?.execute(PROFILE_ADDRESS_TWO, [call])
console.log('execution-response=:', Resp)
} catch (error) {
console.log(error)
}

}

const execute_make_post = async() =>{


// assume this is community_id is 1, since SDK does not return functionn final return value after execution
// https://github.com/horuslabsio/tokenbound-sdk/blob/develop/src/TokenboundClient.ts#L155
let post_params = {
content_URI: "Content URL ...",
profile_address: PROFILE_ADDRESS_TWO,
channel_id: "0x1",
community_id: "0x1"
};

let call:Call = {
to:coloniz_HUB_CONTRACT_ADDRESS,
selector:"0x03023f17c6c151428a83e388ec4de34e239b102d8cb4b01068f4cdc2ed6b83b6",
calldata:[post_params]
}
try {
const Resp = await tokenbound?.execute(PROFILE_ADDRESS_TWO, [call])
console.log('execution-response=:', Resp)
} catch (error) {
console.log(error)
}

}

// comment
const execute_add_comment = async() =>{

// assume this is community_id is 1, since SDK does not return functionn final return value after execution
// https://github.com/horuslabsio/tokenbound-sdk/blob/develop/src/TokenboundClient.ts#L155
let post_params = {
content_URI: "Content URL ...",
profile_address: PROFILE_ADDRESS_TWO,
channel_id: "0x1",
community_id: "0x1"
};

let call:Call = {
to:coloniz_HUB_CONTRACT_ADDRESS,
selector:"0x03023f17c6c151428a83e388ec4de34e239b102d8cb4b01068f4cdc2ed6b83b6",
calldata:[post_params]
}
try {
const Resp = await tokenbound?.execute(PROFILE_ADDRESS_TWO, [call])
console.log('execution-response=:', Resp)
} catch (error) {
console.log(error)
}

}

const execute_comment = async () => {
let call: Call = {
to: coloniz_HUB_CONTRACT_ADDRESS,
selector:
"0x29ce70c72e2e7191b71ef82881773fbf30510f24a3450f02d555b5f04ac9702",
calldata: [{
content_URI: "test comment publication...",
profile_address: PROFILE_ADDRESS_TWO,
pointed_profile_address: PROFILE_ADDRESS_ONE,
pointed_pub_id: "0x1",
reference_pub_type: "Comment",
}],
};
try {
const Resp = await tokenbound?.execute(PROFILE_ADDRESS_TWO, [call]);
console.log("execution-response=:", Resp);
} catch (error) {
console.log(error);
}
};

const execute_repost = async () => {
let call: Call = {
to: coloniz_HUB_CONTRACT_ADDRESS,
selector:
"0x01d2dbb7f2c4890417100d064e363f8dc67af1dbdf7fd6cc9538d82c7566c39b",
calldata: [{
profile_address: PROFILE_ADDRESS_TWO,
pointed_profile_address: PROFILE_ADDRESS_ONE,
pointed_pub_id: "0x1",
}],
};
try {
const Resp = await tokenbound?.execute(PROFILE_ADDRESS_TWO, [call]);
console.log("execution-response=:", Resp);
} catch (error) {
console.log(error);
}
};


const execute_upvote = async () => {
let call: Call = {
to: coloniz_HUB_CONTRACT_ADDRESS,
selector:
"0x02051ad9768cb00721e0522429c7257f589ea08adf6eb43865204cf1cc60b61c",
calldata: [PROFILE_ADDRESS_TWO, "0x1"],
};
try {
const Resp = await tokenbound?.execute(PROFILE_ADDRESS_TWO, [call]);
console.log("execution-response=:", Resp);
} catch (error) {
console.log(error);
}
};

const execute_downvote = async () => {
let call: Call = {
to: coloniz_HUB_CONTRACT_ADDRESS,
selector:
"0x4cbaff62234695102a38001164ecf4c8534f4771b1eabdf5c19fd8384157a5",
calldata: [PROFILE_ADDRESS_TWO, "0x1"],
};
try {
const Resp = await tokenbound?.execute(PROFILE_ADDRESS_TWO, [call]);
console.log("execution-response=:", Resp);
} catch (error) {
console.log(error);
}
};

// create subscription
const create_subscription = async() => {
let erc20_address:string = "0x006e1698dcd0665757dd213a59aff489624bab8c970ce0482c23937a78879b04";
let admin: string = "0x075a4558a2e9d8b10fdb3d94d51b35312703cc7aae43a1ff95e234512e83783f";
let amount = cairo.uint256(50);

let call: Call = {
to: coloniz_HUB_CONTRACT_ADDRESS,
selector:
"0x030326c786e65473aacbd943f9dfef0e20cc86348cecd85b2aae83177847887b",
calldata: CallData.compile([admin, amount, erc20_address]),
}

try {
const Resp = await tokenbound?.execute("0x075a4558a2e9d8b10fdb3d94d51b35312703cc7aae43a1ff95e234512e83783f", [call]);
console.log("execution-response=:", Resp);
} catch (error) {
console.log(error);
}
}

// execute upgrade
const execute_upgrade = async() => {
let community_id = cairo.uint256(5);
let community_type = new CairoCustomEnum({ Business: {} });
let erc20_address:string = "0x006e1698dcd0665757dd213a59aff489624bab8c970ce0482c23937a78879b04";
let sub_id: Uint256 = cairo.uint256(
'0x040e69be8f56d2da824600bc2861852e77f233e43ca1dce3152c9c08f671af87'
);

let call1: Call = {
to: erc20_address,
selector:
"0x0219209e083275171774dab1df80982e9df2096516f06319c5c6d71ae0a8480c",
calldata: CallData.compile([coloniz_HUB_CONTRACT_ADDRESS, cairo.uint256(50)]),
}

const contractCallData: CallData = new CallData(abi);
let call2: Call = {
to: coloniz_HUB_CONTRACT_ADDRESS,
selector:
"0x027ead9fee9c84e7422ab84c28d91eea938d139fafc7d1102ef3982f3d087f88",
calldata: contractCallData.compile('upgrade_community', [community_id, community_type, sub_id, false, cairo.uint256(0)]),
}

try {
const Resp = await tokenbound?.execute("0x075a4558a2e9d8b10fdb3d94d51b35312703cc7aae43a1ff95e234512e83783f", [call1, call2]);
console.log("execution-response=:", Resp);
} catch (error) {
console.log(error);
}
}

// execute gatekeep
const execute_gatekeep = async() =>{
let community_id = cairo.uint256(4);
let gatekeep_type = new CairoCustomEnum({ [GateKeepType.PermissionedGating]: {} });
let permissioned_address = [1, "0x075a4558a2e9d8b10fdb3d94d51b35312703cc7aae43a1ff95e234512e83783f"];
let erc20_address:string = "0x006e1698dcd0665757dd213a59aff489624bab8c970ce0482c23937a78879b04";
let amount = cairo.uint256(50);
let erc721_address = "0x0000003697660a0981d734780731949ecb2b4a38d6a58fc41629ed611e8defda";
let paid_gating_details = {
"0": erc20_address,
"1": amount
};
const contractCallData: CallData = new CallData(abi);

let call: Call = {
to: coloniz_HUB_CONTRACT_ADDRESS,
selector:
"0x3494f4762774ed2020c6906a4da6be06137fc4a0a5ee07fbb404b10c1ae60e8",
calldata: contractCallData.compile('gatekeep', {
community_id: community_id,
gate_keep_type: gatekeep_type,
nft_contract_address: erc721_address,
permissioned_addresses: permissioned_address,
paid_gating_details
}),
}
try {
const Resp = await tokenbound?.execute("0x075a4558a2e9d8b10fdb3d94d51b35312703cc7aae43a1ff95e234512e83783f", [call]);
console.log("execution-response=:", Resp);
} catch (error) {
console.log(error);
}
}

// execute_get_community();
// execute_create_community();
// execute_upgrade()
execute_gatekeep()
// create_subscription()
// execute_create_channel();
// execute_join_community();
// execute_make_post();
// execute_add_comment()
// execute_comment();
// execute_repost();
// execute_upvote();
// execute_downvote();


2 changes: 1 addition & 1 deletion scripts/src/helpers/constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const HANDLE_CONTRACT_ADDRESS:string = "0x4cb40ffd9120ab0ff7632fe27710d5f979ad18e1294737ac5838ad7a437677a";
export const REGISTRY_HANDLE_CONTRACT_ADDRESS:string = "0x7d750ed304612f346b9ca5555e26fc80b279487b90d56e86a07668b9f1b6492";
export const coloniz_NFT_CONTRACT_ADDRESS:string = "0x4dca9ec1ed78ce5cddbbcec63d3620514ae66bc73a3942d48a011bad452ffe"
export const coloniz_HUB_CONTRACT_ADDRESS:string ="0x7e3c4c5275b93d985699b86486848b0bee8d75b88fbaf36fea339eeb74b8aa8"
export const coloniz_HUB_CONTRACT_ADDRESS:string ="0x04bd89ef797c5a34a3c8bcc9dafca270959d9edcd568ea22a2364ffb3af959f0"
export const FOLLOW_CONTRACT_ADDRESS:string = "0x60a56d724558a9cfbbf3a3fd4faebaa65678efe090d3dd49afa85d1bcc61eba"
export const PROFILE_ADDRESS_ONE:string = "0x206b999eeed11da16898664d6ad251563e6796a564c6eaddfae4d84350d4cf1";
export const PROFILE_ADDRESS_TWO:string = "0x75a4558a2e9d8b10fdb3d94d51b35312703cc7aae43a1ff95e234512e83783f"
2 changes: 1 addition & 1 deletion scripts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {WalletClient, TBAChainID, TBAVersion, TokenboundClient} from "starknet-t

const walletClient: WalletClient = {
address: "0x07EadF65B6D96A7DEbB36380fF936F6701a053Be8f2824D6293f188fA542C502",
privateKey: process.env.ACCOUNT_TWO_PRIVATE_KEY!,
privateKey: "",
};
const options = {
walletClient: walletClient,
Expand Down
2 changes: 2 additions & 0 deletions src/base/constants/errors.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub mod Errors {
pub const FOLLOWING: felt252 = 'coloniz: already following!';
pub const NOT_FOLLOWING: felt252 = 'coloniz: user not following!';
pub const BLOCKED_STATUS: felt252 = 'coloniz: user is blocked!';
pub const USER_NOT_BLOCKED: felt252 = 'coloniz: user is not blocked!';
pub const INVALID_POINTED_PUBLICATION: felt252 = 'coloniz: invalid pointed pub!';
pub const INVALID_OWNER: felt252 = 'coloniz: caller is not owner!';
pub const INVALID_PROFILE: felt252 = 'coloniz: profile is not owner!';
Expand All @@ -24,6 +25,7 @@ pub mod Errors {
pub const COMMUNITY_DOES_NOT_EXIST: felt252 = 'coloniz: Comm does not exist';
pub const NOT_COMMUNITY_OWNER: felt252 = 'coloniz: Not Community owner';
pub const ONLY_PREMIUM_COMMUNITIES: felt252 = 'coloniz: not premium community';
pub const INVALID_UPGRADE: felt252 = 'coloniz: invalid upgrade type';
pub const NOT_COMMUNITY_MEMBER: felt252 = 'coloniz: Not Community Member';
pub const NOT_COMMUNITY_MOD: felt252 = 'coloniz: Not a community mod';
pub const BANNED_MEMBER: felt252 = 'coloniz: Profile is banned!';
Expand Down
Loading

0 comments on commit 8f8cc24

Please sign in to comment.