Skip to content

Commit

Permalink
feat : Added stream_id in the LockupLinearStream struct
Browse files Browse the repository at this point in the history
  • Loading branch information
Akashneelesh committed Jan 28, 2024
1 parent 759693d commit 1a8ee0e
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
7 changes: 7 additions & 0 deletions src/core/lockup_linear.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@ mod TokeiLockupLinear {

if (TokeiInternalImpl::_status_of(self, stream_id) == Status::SETTLED) {
let stream_updated = LockupLinearStream {
stream_id: stream.stream_id,
sender: stream.sender,
asset: stream.asset,
recipient: stream.recipient,
Expand Down Expand Up @@ -1447,6 +1448,7 @@ mod TokeiLockupLinear {
assert(amount <= withdrawable_amount, OVERDRAW);
let stream = self.streams.read(stream_id);
let stream_updated = LockupLinearStream {
stream_id: stream.stream_id,
sender: stream.sender,
asset: stream.asset,
recipient: stream.recipient,
Expand All @@ -1470,6 +1472,7 @@ mod TokeiLockupLinear {

if (amounts.withdrawn >= amounts.deposited - amounts.refunded) {
let _stream_updated = LockupLinearStream {
stream_id: stream.stream_id,
sender: stream.sender,
asset: stream.asset,
recipient: stream.recipient,
Expand Down Expand Up @@ -1503,6 +1506,7 @@ mod TokeiLockupLinear {
// Checks: the stream is cancelable.
assert(stream.is_cancelable, STREAM_NOT_CANCELABLE);
let stream_updated = LockupLinearStream {
stream_id: stream.stream_id,
sender: stream.sender,
asset: stream.asset,
recipient: stream.recipient,
Expand Down Expand Up @@ -1546,6 +1550,7 @@ mod TokeiLockupLinear {

if (recipient_amount == 0) {
let stream_updated = LockupLinearStream {
stream_id: stream.stream_id,
sender: stream.sender,
asset: stream.asset,
recipient: stream.recipient,
Expand All @@ -1567,6 +1572,7 @@ mod TokeiLockupLinear {
self.streams.write(stream_id, stream_updated);
} else {
let stream_updated = LockupLinearStream {
stream_id: stream.stream_id,
sender: stream.sender,
asset: stream.asset,
recipient: stream.recipient,
Expand Down Expand Up @@ -1702,6 +1708,7 @@ mod TokeiLockupLinear {

// Effects: create the stream.
let stream = LockupLinearStream {
stream_id: stream_id,
sender,
asset,
recipient,
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/admin_interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ export async function initialize_account() {
"0x075b1b684be1cd0f08a4a59a22994dedb6d3f5851e630b3f1a895459ef754e87";

const tokeiClassHash =
"0x0642757913747e242c09cbbe73a3ab5733dfde42bc9293ed1b3642202dde7ff8";
"0x01f9313b620810859fb1aa2b6920bb80a00d6bf5b13d1329b9a82424c8c272ab";
const tokeiaddress =
"0x682799e0ba490a32a4e24cf8a349b8d3560ee48f7ef2b9349b5cb4a527e99ae";
"0x04bf83b5554b165b5f0ff5e797a8f57162840c78915b4864bdbfbdc71649ef1b";

console.log("✅ ERC20 Contract declared with classHash =", erc20ClassHash);
console.log("✅ Tokei Contract declared with classHash =", tokeiClassHash);
Expand Down
5 changes: 2 additions & 3 deletions src/scripts/deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async function main() {
//**************************************************************************************** */

const contractClassHash =
"0x0642757913747e242c09cbbe73a3ab5733dfde42bc9293ed1b3642202dde7ff8";
"0x01f9313b620810859fb1aa2b6920bb80a00d6bf5b13d1329b9a82424c8c272ab";

console.log("✅ Test Contract declared with classHash =", contractClassHash);

Expand All @@ -90,5 +90,4 @@ main()
});

//Deployed Address
// Updated deployed contract address: 0x682799e0ba490a32a4e24cf8a349b8d3560ee48f7ef2b9349b5cb4a527e99ae
// 0x0661bd47eb4c872cd316a305dc673221a8f8a27379e6aa3a97a21a542efbb76f on goerli
// Updated deployed contract_address : 0x04bf83b5554b165b5f0ff5e797a8f57162840c78915b4864bdbfbdc71649ef1b on goerli
3 changes: 3 additions & 0 deletions src/tests/test_lockup_linear.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ fn test_create_with_duration() {
let expected_Broker_balance = 3;
let expected_protocol_revenue = 1;
let expected_stream = LockupLinearStream {
stream_id: 1,
sender: ALICE(),
asset: token,
recipient: RECIPIENT(),
Expand Down Expand Up @@ -576,6 +577,7 @@ fn test_get_stream_when_status_settled() {

let actual_stream = tokei.get_stream(stream_id);
let expected_stream = LockupLinearStream {
stream_id: 1,
sender: ALICE(),
asset: token.contract_address,
recipient: RECIPIENT(),
Expand All @@ -602,6 +604,7 @@ fn test_get_stream_when_not_settled() {
let actual_stream = tokei.get_stream(stream_id);

let expected_stream = LockupLinearStream {
stream_id: 1,
sender: ALICE(),
asset: token.contract_address,
recipient: RECIPIENT(),
Expand Down
1 change: 1 addition & 0 deletions src/tests/utils/defaults.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ mod Defaults {
fn lockup_linear_stream() -> LockupLinearStream {
let (START_TIME, CLIFF_TIME, END_TIME) = setup_1();
LockupLinearStream {
stream_id: 1,
sender: contract_address_const::<'sender'>(),
asset: contract_address_const::<'asset'>(),
recipient: contract_address_const::<'recipient'>(),
Expand Down
2 changes: 2 additions & 0 deletions src/types/lockup_linear.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ use tokei::types::lockup::LockupAmounts;
/// Represent a Lockup Linear Stream.
#[derive(Copy, Drop, starknet::Store, Serde, PartialEq)]
struct LockupLinearStream {
/// The stream's ID.
stream_id: u64,
/// The address streaming the assets, with the ability to cancel the stream.
sender: ContractAddress,
/// The contract address of the ERC-20 asset used for streaming.
Expand Down

0 comments on commit 1a8ee0e

Please sign in to comment.