Skip to content

Commit

Permalink
Merge branch 'ArkProjectNFTs:main' into od-hunter-refac
Browse files Browse the repository at this point in the history
  • Loading branch information
od-hunter authored Oct 4, 2024
2 parents 3396f08 + 229d3dc commit 1990109
Show file tree
Hide file tree
Showing 38 changed files with 1,015 additions and 1,588 deletions.
14 changes: 4 additions & 10 deletions apps/blockchain/ethereum/script/ERC1155.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,17 @@ import "./Utils.sol";
import "src/token/ERC1155Bridgeable.sol";
import "openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Proxy.sol";


contract Deploy is Script {

function setUp() public {
}
function setUp() public {}

function run() public {
Config memory config = Utils.loadConfig();

vm.startBroadcast(config.deployerPrivateKey);

address impl = address(new ERC1155Bridgeable());

bytes memory dataInit = abi.encodeWithSelector(
ERC1155Bridgeable.initialize.selector,
abi.encode("")
);

bytes memory dataInit = abi.encodeWithSelector(ERC1155Bridgeable.initialize.selector, abi.encode(""));

address proxyAddress = vm.envAddress("ERC1155_PROXY_ADDRESS");

Expand Down
18 changes: 5 additions & 13 deletions apps/blockchain/ethereum/script/ERC721.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,18 @@ import "./Utils.sol";
import "src/token/ERC721Bridgeable.sol";
import "openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Proxy.sol";


contract Deploy is Script {

function setUp() public {
}
function setUp() public {}

function run() public {
Config memory config = Utils.loadConfig();

vm.startBroadcast(config.deployerPrivateKey);

address impl = address(new ERC721Bridgeable());

bytes memory dataInit = abi.encodeWithSelector(
ERC721Bridgeable.initialize.selector,
abi.encode(
"everai_123",
"EVR_123"
)
);

bytes memory dataInit =
abi.encodeWithSelector(ERC721Bridgeable.initialize.selector, abi.encode("everai_123", "EVR_123"));

address proxyAddress = vm.envAddress("ERC721_PROXY_ADDRESS");

Expand Down
5 changes: 2 additions & 3 deletions apps/blockchain/ethereum/script/LocalMessaging.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ import "forge-std/Script.sol";

import "./Utils.sol";


import "src/sn/StarknetMessagingLocal.sol";

contract LocalMessaging is Script {
function setUp() public {}

function run() public {
Config memory config = Utils.loadConfig();

string memory json = "local_messaging";
vm.startBroadcast(config.deployerPrivateKey);

Expand All @@ -23,4 +22,4 @@ contract LocalMessaging is Script {

Utils.writeJson(json, "local_messaging_deploy.json");
}
}
}
44 changes: 11 additions & 33 deletions apps/blockchain/ethereum/script/LocalTesting.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ import "src/token/ERC721Bridgeable.sol";
import "openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Proxy.sol";
import "openzeppelin-contracts/contracts/token/ERC721/IERC721.sol";


/**
Deploys a local setup with:
1. Local SN Core contract to receive/send messages.
2. Starklane bridge.
3. One ERC721b collection with 10 tokens minted for the deployer.
4. One request on the bridge depositing tokens.
*/
* Deploys a local setup with:
* 1. Local SN Core contract to receive/send messages.
* 2. Starklane bridge.
* 3. One ERC721b collection with 10 tokens minted for the deployer.
* 4. One request on the bridge depositing tokens.
*/
contract LocalSetup is Script {
function setUp() public {}

Expand All @@ -38,25 +37,15 @@ contract LocalSetup is Script {

bytes memory dataInit = abi.encodeWithSelector(
Starklane.initialize.selector,
abi.encode(
config.deployerAddress,
snCoreAddress,
config.starklaneL2Address,
config.starklaneL2Selector
)
abi.encode(config.deployerAddress, snCoreAddress, config.starklaneL2Address, config.starklaneL2Selector)
);
address starklaneProxyAddress = address(new ERC1967Proxy(starklaneImpl, dataInit));

// ERC721b.
address erc721Impl = address(new ERC721Bridgeable());

bytes memory erc721DataInit = abi.encodeWithSelector(
ERC721Bridgeable.initialize.selector,
abi.encode(
"collection_1",
"C1"
)
);
bytes memory erc721DataInit =
abi.encodeWithSelector(ERC721Bridgeable.initialize.selector, abi.encode("collection_1", "C1"));

address erc721ProxyAddress = address(new ERC1967Proxy(erc721Impl, erc721DataInit));

Expand All @@ -68,12 +57,7 @@ contract LocalSetup is Script {

// Mint some tokens.
(bool success, bytes memory data) = erc721ProxyAddress.call(
abi.encodeWithSignature(
"mintRangeFree(address,uint256,uint256)",
config.deployerAddress,
0,
20
)
abi.encodeWithSignature("mintRangeFree(address,uint256,uint256)", config.deployerAddress, 0, 20)
);

// set approval to then deposit tokens.
Expand All @@ -87,13 +71,7 @@ contract LocalSetup is Script {
uint256 salt = 0x1;
snaddress to = Cairo.snaddressWrap(0x12345);

IStarklane(starklaneProxyAddress).depositTokens{value: 30000}(
salt,
address(erc721ProxyAddress),
to,
ids,
false
);
IStarklane(starklaneProxyAddress).depositTokens{value: 30000}(salt, address(erc721ProxyAddress), to, ids, false);

vm.stopBroadcast();

Expand Down
1 change: 0 additions & 1 deletion apps/blockchain/ethereum/script/Starklane.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import "src/token/ERC721Bridgeable.sol";

import "openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Proxy.sol";


contract Deploy is Script {
function setUp() public {}

Expand Down
17 changes: 4 additions & 13 deletions apps/blockchain/ethereum/script/Utils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,29 @@ address constant HEVM_ADDRESS = address(bytes20(uint160(uint256(keccak256("hevm
struct Config {
address deployerAddress;
uint256 deployerPrivateKey;

address starknetCoreAddress;
address starklaneL1ProxyAddress;

uint256 starklaneL2Address;
uint256 starklaneL2Selector;
}

library Utils {

//
function loadConfig()
internal
view
returns (Config memory) {
function loadConfig() internal view returns (Config memory) {
VmSafe vm = VmSafe(HEVM_ADDRESS);

return Config({
deployerAddress: vm.envAddress("ACCOUNT_ADDRESS"),
deployerPrivateKey: vm.envUint("ACCOUNT_PRIVATE_KEY"),

starknetCoreAddress: vm.envAddress("STARKNET_CORE_L1_ADDRESS"),
starklaneL1ProxyAddress: vm.envAddress("STARKLANE_L1_PROXY_ADDRESS"),

starklaneL2Address: vm.envUint("STARKLANE_L2_ADDRESS"),
starklaneL2Selector: vm.envUint("STARKLANE_L2_SELECTOR")
});
});
}

//
function writeJson(string memory json, string memory fileName)
internal {
function writeJson(string memory json, string memory fileName) internal {
VmSafe vm = VmSafe(HEVM_ADDRESS);

string memory data = vm.serializeBool(json, "success", true);
Expand Down
Loading

0 comments on commit 1990109

Please sign in to comment.