@@ -3,18 +3,21 @@ import { PublicKey } from "@solana/web3.js";
3
3
import { BN } from "@project-serum/anchor" ;
4
4
5
5
const LE = "le" ; //little endian
6
- const instructionsFields = [
6
+
7
+ const StreamInstructionLayout = BufferLayout . struct < StreamInstruction > ( [
7
8
BufferLayout . blob ( 8 , "start_time" ) ,
8
9
BufferLayout . blob ( 8 , "end_time" ) ,
9
10
BufferLayout . blob ( 8 , "deposited_amount" ) ,
10
11
BufferLayout . blob ( 8 , "total_amount" ) ,
11
12
BufferLayout . blob ( 8 , "period" ) ,
12
13
BufferLayout . blob ( 8 , "cliff" ) ,
13
14
BufferLayout . blob ( 8 , "cliff_amount" ) ,
14
- ] ;
15
-
16
- const StreamInstructionLayout =
17
- BufferLayout . struct < StreamInstruction > ( instructionsFields ) ;
15
+ BufferLayout . blob ( 1 , "is_cancelable_by_sender" ) ,
16
+ BufferLayout . blob ( 1 , "is_cancelable_by_recipient" ) ,
17
+ BufferLayout . blob ( 1 , "is_withdrawal_public" ) ,
18
+ BufferLayout . blob ( 1 , "is_transferable" ) ,
19
+ BufferLayout . blob ( 4 , "padding" ) ,
20
+ ] ) ;
18
21
19
22
function decode_stream_instruction ( buf : Buffer ) {
20
23
let raw = StreamInstructionLayout . decode ( buf ) ;
@@ -29,69 +32,86 @@ function decode_stream_instruction(buf: Buffer) {
29
32
} ;
30
33
}
31
34
32
- const TokenStreamDataLayout = BufferLayout . struct < Stream > ( [
35
+ interface StreamInstruction {
36
+ start_time : BN ;
37
+ end_time : BN ;
38
+ deposited_amount : BN ;
39
+ total_amount : BN ;
40
+ period : BN ;
41
+ cliff : BN ;
42
+ cliff_amount : BN ;
43
+ }
44
+
45
+ const TokenStreamDataLayout = BufferLayout . struct < TokenStreamData > ( [
33
46
BufferLayout . blob ( 8 , "magic" ) ,
34
- ...instructionsFields ,
35
47
BufferLayout . blob ( 8 , "created_at" ) ,
36
- BufferLayout . blob ( 8 , "withdrawn" ) ,
37
- BufferLayout . blob ( 8 , "cancel_time" ) ,
48
+ BufferLayout . blob ( 8 , "withdrawn_amount" ) ,
49
+ BufferLayout . blob ( 8 , "canceled_at" ) ,
50
+ BufferLayout . blob ( 8 , "cancellable_at" ) ,
51
+ BufferLayout . blob ( 8 , "last_withdrawn_at" ) ,
38
52
BufferLayout . blob ( 32 , "sender" ) ,
39
53
BufferLayout . blob ( 32 , "sender_tokens" ) ,
40
54
BufferLayout . blob ( 32 , "recipient" ) ,
41
55
BufferLayout . blob ( 32 , "recipient_tokens" ) ,
42
56
BufferLayout . blob ( 32 , "mint" ) ,
43
57
BufferLayout . blob ( 32 , "escrow_tokens" ) ,
58
+ BufferLayout . blob ( 8 , "start_time" ) ,
59
+ BufferLayout . blob ( 8 , "end_time" ) ,
60
+ BufferLayout . blob ( 8 , "deposited_amount" ) ,
61
+ BufferLayout . blob ( 8 , "total_amount" ) ,
62
+ BufferLayout . blob ( 8 , "period" ) ,
63
+ BufferLayout . blob ( 8 , "cliff" ) ,
64
+ BufferLayout . blob ( 8 , "cliff_amount" ) ,
65
+ BufferLayout . blob ( 1 , "is_cancelable_by_sender" ) ,
66
+ BufferLayout . blob ( 1 , "is_cancelable_by_recipient" ) ,
67
+ BufferLayout . blob ( 1 , "is_withdrawal_public" ) ,
68
+ BufferLayout . blob ( 1 , "is_transferable" ) ,
69
+ BufferLayout . blob ( 4 , "padding" ) ,
44
70
] ) ;
45
71
46
72
export function decode ( buf : Buffer ) {
47
73
let raw = TokenStreamDataLayout . decode ( buf ) ;
48
74
return {
49
75
magic : new BN ( raw . magic , LE ) ,
50
- start_time : new BN ( raw . start_time , LE ) ,
51
- end_time : new BN ( raw . end_time , LE ) ,
52
- deposited_amount : new BN ( raw . deposited_amount , LE ) ,
53
- total_amount : new BN ( raw . total_amount , LE ) ,
54
- period : new BN ( raw . period , LE ) ,
55
- cliff : new BN ( raw . cliff , LE ) ,
56
- cliff_amount : new BN ( raw . cliff_amount , LE ) ,
57
76
created_at : new BN ( raw . created_at , LE ) ,
58
- withdrawn : new BN ( raw . withdrawn , LE ) ,
59
- cancel_time : new BN ( raw . cancel_time , LE ) ,
77
+ withdrawn_amount : new BN ( raw . withdrawn_amount , LE ) ,
78
+ canceled_at : new BN ( raw . canceled_at , LE ) ,
79
+ cancellable_at : new BN ( raw . cancellable_at , LE ) ,
80
+ last_withdrawn_at : new BN ( raw . last_withdrawn_at , LE ) ,
60
81
sender : new PublicKey ( raw . sender ) ,
61
82
sender_tokens : new PublicKey ( raw . sender_tokens ) ,
62
83
recipient : new PublicKey ( raw . recipient ) ,
63
84
recipient_tokens : new PublicKey ( raw . recipient_tokens ) ,
64
85
mint : new PublicKey ( raw . mint ) ,
65
86
escrow_tokens : new PublicKey ( raw . escrow_tokens ) ,
87
+ start_time : new BN ( raw . start_time , LE ) ,
88
+ end_time : new BN ( raw . end_time , LE ) ,
89
+ deposited_amount : new BN ( raw . deposited_amount , LE ) ,
90
+ total_amount : new BN ( raw . total_amount , LE ) ,
91
+ period : new BN ( raw . period , LE ) ,
92
+ cliff : new BN ( raw . cliff , LE ) ,
93
+ cliff_amount : new BN ( raw . cliff_amount , LE ) ,
66
94
} ;
67
95
}
68
96
69
- export interface StreamInstruction {
70
- start_time : BN ;
71
- end_time : BN ;
72
- deposited_amount : BN ;
73
- total_amount : BN ;
74
- period : BN ;
75
- cliff : BN ;
76
- cliff_amount : BN ;
77
- }
78
-
79
- export interface Stream {
97
+ export interface TokenStreamData {
80
98
magic : BN ;
81
- start_time : BN ;
82
- end_time : BN ;
83
- deposited_amount : BN ;
84
- total_amount : BN ;
85
- period : BN ;
86
- cliff : BN ;
87
- cliff_amount : BN ;
88
99
created_at : BN ;
89
- withdrawn : BN ;
90
- cancel_time : BN ;
100
+ withdrawn_amount : BN ;
101
+ canceled_at : BN ;
102
+ cancellable_at : BN ;
103
+ last_withdrawn_at : BN ;
91
104
sender : PublicKey ;
92
105
sender_tokens : PublicKey ;
93
106
recipient : PublicKey ;
94
107
recipient_tokens : PublicKey ;
95
108
mint : PublicKey ;
96
109
escrow_tokens : PublicKey ;
110
+ start_time : BN ;
111
+ end_time : BN ;
112
+ deposited_amount : BN ;
113
+ total_amount : BN ;
114
+ period : BN ;
115
+ cliff : BN ;
116
+ cliff_amount : BN ;
97
117
}
0 commit comments