This repository has been archived by the owner on Jan 29, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b3edf3
commit 363e0d0
Showing
147 changed files
with
6,986 additions
and
5,400 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,64 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.23; | ||
|
||
interface IMessenger { | ||
function notify( | ||
bytes32 commitId, | ||
bytes32 hashlock, | ||
string memory dstChain, | ||
string memory dstAsset, | ||
string memory dstAddress, | ||
string memory srcAsset, | ||
address payable sender, | ||
address payable srcReciever, | ||
uint256 amount, | ||
uint256 timelock, | ||
address tokenContract | ||
) external; | ||
} | ||
|
||
contract SimpleMessenger is IMessenger { | ||
event NotificationReceived( | ||
bytes32 indexed lockId, | ||
bytes32 commitId, | ||
bytes32 hashlock, | ||
string dstChain, | ||
string dstAsset, | ||
string dstAddress, | ||
string srcAsset, | ||
address payable sender, | ||
address payable srcReciever, | ||
uint256 amount, | ||
uint256 timelock, | ||
address tokenContract | ||
); | ||
|
||
function notify( | ||
bytes32 commitId, | ||
bytes32 hashlock, | ||
string memory dstChain, | ||
string memory dstAsset, | ||
string memory dstAddress, | ||
string memory srcAsset, | ||
address payable sender, | ||
address payable srcReciever, | ||
uint256 amount, | ||
uint256 timelock, | ||
address tokenContract | ||
) public override { | ||
emit NotificationReceived( | ||
hashlock, | ||
commitId, | ||
hashlock, | ||
dstChain, | ||
dstAsset, | ||
dstAddress, | ||
srcAsset, | ||
sender, | ||
srcReciever, | ||
amount, | ||
timelock, | ||
tokenContract | ||
); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,57 @@ | ||
const ethers = require("ethers"); | ||
require("dotenv").config(); | ||
|
||
async function signHTLC() { | ||
const domain = { | ||
name: "LayerswapV8", | ||
version: "1", | ||
chainId: 421614, | ||
verifyingContract: "0x3E3Abe0752A588e78b6F8926631bBb453d2bddCa", | ||
salt: "0x2e4ff7169d640efc0d28f2e302a56f1cf54aff7e127eededda94b3df0946f5c0" | ||
}; | ||
|
||
// Use ethers.js to encode the domain and compute the domain separator | ||
const domainSeparator = ethers.keccak256( | ||
ethers.AbiCoder.defaultAbiCoder().encode( | ||
['bytes32', 'bytes32', 'bytes32', 'uint256', 'address', 'bytes32'], | ||
[ | ||
ethers.keccak256(ethers.toUtf8Bytes('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract,bytes32 salt)')), | ||
ethers.keccak256(ethers.toUtf8Bytes(domain.name)), | ||
ethers.keccak256(ethers.toUtf8Bytes(domain.version)), | ||
domain.chainId, | ||
domain.verifyingContract, | ||
domain.salt | ||
] | ||
) | ||
); | ||
|
||
console.log('Computed Domain Separator:', domainSeparator); | ||
|
||
const types = { | ||
lockCommitmentMsg: [ | ||
{ name: "hashlock", type: "bytes32" }, | ||
{ name: "timelock", type: "uint256" }, | ||
], | ||
}; | ||
|
||
const message = { | ||
hashlock: "0x928a260e1022cffc1b90018ab7f80ed5b2aef0b25d8c7c6825348811c30c7b8a", | ||
timelock: 1724673591, | ||
}; | ||
|
||
const privateKey = '0xe9ac8d073f52df4c776f16915460806dc5c28c9bc9b510ad074c275c8cff89e9'; | ||
const wallet = new ethers.Wallet(privateKey); | ||
|
||
const signature = await wallet.signTypedData(domain, types, message); | ||
|
||
console.log("Signature:", signature); | ||
|
||
const sig = ethers.Signature.from(signature); | ||
console.log({ | ||
r: sig.r, | ||
s: sig.s, | ||
v: sig.v | ||
}); | ||
} | ||
|
||
signHTLC().catch(console.error); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 @@ | ||
[toolchain] | ||
|
||
[features] | ||
resolution = true | ||
skip-lint = false | ||
|
||
[programs.devnet] | ||
native = "DuHWoXCyDCQBa7oMkZBhvPBJYsPKbuUmusZBeK8vdBtN" | ||
|
||
[registry] | ||
url = "https://api.apr.dev" | ||
|
||
[provider] | ||
cluster = "devnet" | ||
wallet = "~/.config/solana/id.json" | ||
|
||
[scripts] | ||
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts" |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,24 @@ | ||
[package] | ||
name = "sol" | ||
version = "0.1.0" | ||
description = "Created with Anchor" | ||
edition = "2021" | ||
|
||
[lib] | ||
crate-type = ["cdylib", "lib"] | ||
name = "sol" | ||
|
||
|
||
[features] | ||
default = [] | ||
cpi = ["no-entrypoint"] | ||
no-entrypoint = [] | ||
no-idl = [] | ||
no-log-ix-name = [] | ||
idl-build = ["anchor-lang/idl-build"] | ||
|
||
[dependencies] | ||
anchor-lang = { version = "0.30.0" } | ||
num_enum = "0.5.4" | ||
sha2 = "0.10.2" | ||
hex = "0.4.3" |
File renamed without changes.
Oops, something went wrong.