Skip to content

Commit

Permalink
nft: sender and update localnet
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev committed Nov 11, 2024
1 parent b0f3d1b commit 3150e9c
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion examples/hello/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@types/node": ">=12.0.0",
"@typescript-eslint/eslint-plugin": "^5.59.9",
"@typescript-eslint/parser": "^5.59.9",
"@zetachain/localnet": "4.0.0-rc5",
"@zetachain/localnet": "4.0.0-rc6",
"@zetachain/toolkit": "13.0.0-rc7",
"axios": "^1.3.6",
"chai": "^4.2.0",
Expand Down
8 changes: 4 additions & 4 deletions examples/hello/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2743,10 +2743,10 @@
typescript "5.5.4"
zod "3.22.4"

"@zetachain/[email protected]rc5":
version "4.0.0-rc5"
resolved "https://registry.yarnpkg.com/@zetachain/localnet/-/localnet-4.0.0-rc5.tgz#dcb06202250956aba31e979709018b53071e1844"
integrity sha512-zr2rM/9DPtBlvjZVvhuBYbVgYIy81E5Woc09KqYY1DfvdfYzJmtOR1IJULyVBNTArl125ibwl22AxOnKv5ri2g==
"@zetachain/[email protected]rc6":
version "4.0.0-rc6"
resolved "https://registry.yarnpkg.com/@zetachain/localnet/-/localnet-4.0.0-rc6.tgz#9b36f5ab0e8fac766d63cfca4b1cab6a263bdd5d"
integrity sha512-DGKspMAJZLUrgNirc3NzFYg9jRfaOyuF5ePj85D93qAA//f8lOsXpmh/6Bvq/MrEscCLpVavgVP7+ePy4KJ2Fw==
dependencies:
"@inquirer/prompts" "^5.5.0"
"@uniswap/v2-core" "^1.0.1"
Expand Down
14 changes: 8 additions & 6 deletions examples/nft/contracts/Universal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ contract Universal is
error InvalidAddress();
error InvalidGasLimit();

mapping(address => bytes) public counterparty;
mapping(address => address) public counterparty;

modifier onlyGateway() {
if (msg.sender != address(gateway)) revert Unauthorized();
Expand All @@ -57,7 +57,7 @@ contract Universal is

function setCounterparty(
address zrc20,
bytes memory contractAddress
address contractAddress
) external onlyOwner {
counterparty[zrc20] = contractAddress;
emit CounterpartySet(zrc20, contractAddress);
Expand Down Expand Up @@ -92,7 +92,7 @@ contract Universal is
);

gateway.call(
counterparty[destination],
abi.encodePacked(counterparty[destination]),
destination,
message,
callOptions,
Expand All @@ -115,14 +115,16 @@ contract Universal is
_setTokenURI(tokenId, uri);
}

event Foo(address);

function onCall(
MessageContext calldata context,
address zrc20,
uint256 amount,
bytes calldata message
) external override onlyGateway {
if (keccak256(context.origin) != keccak256(counterparty[zrc20]))
revert("Unauthorized");
emit Foo(context.sender);
if (context.sender != counterparty[zrc20]) revert("Unauthorized");

(
uint256 tokenId,
Expand Down Expand Up @@ -150,7 +152,7 @@ contract Universal is

IZRC20(destination).approve(address(gateway), gasFee);
gateway.call(
counterparty[destination],
abi.encodePacked(counterparty[destination]),
destination,
abi.encode(tokenId, sender, uri),
CallOptions(gasLimit, false),
Expand Down
2 changes: 1 addition & 1 deletion examples/nft/contracts/shared/Events.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ contract Events {
address indexed sender,
string uri
);
event CounterpartySet(address indexed zrc20, bytes indexed contractAddress);
event CounterpartySet(address indexed zrc20, address contractAddress);
event TokenTransferToDestination(
uint256 indexed tokenId,
address indexed sender,
Expand Down
2 changes: 1 addition & 1 deletion examples/nft/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@types/node": ">=12.0.0",
"@typescript-eslint/eslint-plugin": "^5.59.9",
"@typescript-eslint/parser": "^5.59.9",
"@zetachain/localnet": "4.0.0-rc4",
"@zetachain/localnet": "4.0.0-rc6",
"@zetachain/toolkit": "13.0.0-rc7",
"axios": "^1.3.6",
"chai": "^4.2.0",
Expand Down
8 changes: 4 additions & 4 deletions examples/nft/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2743,10 +2743,10 @@
typescript "5.5.4"
zod "3.22.4"

"@zetachain/[email protected]rc4":
version "4.0.0-rc4"
resolved "https://registry.yarnpkg.com/@zetachain/localnet/-/localnet-4.0.0-rc4.tgz#916c58f83dd4901691fbc1216aec2ee88e7f531e"
integrity sha512-yNlA6qaQZiuHXRx4pgNLLHlJ+2ENet9WTIWxoslnLzzDljWwYTJHkErlTQcWa5oL9jjyn2/hQB/laoqXzlX1gQ==
"@zetachain/[email protected]rc6":
version "4.0.0-rc6"
resolved "https://registry.yarnpkg.com/@zetachain/localnet/-/localnet-4.0.0-rc6.tgz#9b36f5ab0e8fac766d63cfca4b1cab6a263bdd5d"
integrity sha512-DGKspMAJZLUrgNirc3NzFYg9jRfaOyuF5ePj85D93qAA//f8lOsXpmh/6Bvq/MrEscCLpVavgVP7+ePy4KJ2Fw==
dependencies:
"@inquirer/prompts" "^5.5.0"
"@uniswap/v2-core" "^1.0.1"
Expand Down
2 changes: 1 addition & 1 deletion examples/swap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@types/node": ">=12.0.0",
"@typescript-eslint/eslint-plugin": "^5.59.9",
"@typescript-eslint/parser": "^5.59.9",
"@zetachain/localnet": "4.0.0-rc5",
"@zetachain/localnet": "4.0.0-rc6",
"axios": "^1.3.6",
"chai": "^4.2.0",
"dotenv": "^16.0.3",
Expand Down
8 changes: 4 additions & 4 deletions examples/swap/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2481,10 +2481,10 @@
typescript "5.5.4"
zod "3.22.4"

"@zetachain/[email protected]rc5":
version "4.0.0-rc5"
resolved "https://registry.yarnpkg.com/@zetachain/localnet/-/localnet-4.0.0-rc5.tgz#dcb06202250956aba31e979709018b53071e1844"
integrity sha512-zr2rM/9DPtBlvjZVvhuBYbVgYIy81E5Woc09KqYY1DfvdfYzJmtOR1IJULyVBNTArl125ibwl22AxOnKv5ri2g==
"@zetachain/[email protected]rc6":
version "4.0.0-rc6"
resolved "https://registry.yarnpkg.com/@zetachain/localnet/-/localnet-4.0.0-rc6.tgz#9b36f5ab0e8fac766d63cfca4b1cab6a263bdd5d"
integrity sha512-DGKspMAJZLUrgNirc3NzFYg9jRfaOyuF5ePj85D93qAA//f8lOsXpmh/6Bvq/MrEscCLpVavgVP7+ePy4KJ2Fw==
dependencies:
"@inquirer/prompts" "^5.5.0"
"@uniswap/v2-core" "^1.0.1"
Expand Down

0 comments on commit 3150e9c

Please sign in to comment.