@@ -189,7 +189,7 @@ suite('serializer', function () {
189
189
const decoded = Serializer . decode ( { data : encoded , type : Test } )
190
190
assert . equal (
191
191
JSON . stringify ( decoded ) ,
192
- '{"foo":"bar","things":["a","b","c"],"keys":null," other":{"doeet":true}}'
192
+ '{"foo":"bar","things":["a","b","c"],"other":{"doeet":true}}'
193
193
)
194
194
} )
195
195
@@ -769,7 +769,6 @@ suite('serializer', function () {
769
769
things : [ 'do_you_even' , 2 ] ,
770
770
self : {
771
771
things : [ 'do_you_even' , '-170141183460469231731687303715884105727' ] ,
772
- self : null ,
773
772
} ,
774
773
} ,
775
774
} )
@@ -912,7 +911,6 @@ suite('serializer', function () {
912
911
assert . deepEqual ( JSON . parse ( JSON . stringify ( decoded ) ) , {
913
912
foo : 'hello' ,
914
913
bar : [ 1 , 'two' , false ] ,
915
- baz : null ,
916
914
account : 'foobar1234' ,
917
915
} )
918
916
const abi = Serializer . synthesize ( MyStruct )
@@ -1137,7 +1135,7 @@ suite('serializer', function () {
1137
1135
assert . equal ( res1 . asset . toString ( ) , '0.0000 SYS' )
1138
1136
assert . equal ( res1 . superInt . toNumber ( ) , 42 )
1139
1137
assert . equal ( res1 . jazz . value , 42 )
1140
- assert . strictEqual ( res1 . maybeJazz , null )
1138
+ assert . notProperty ( res1 , 'maybeJazz' )
1141
1139
assert . strictEqual ( res1 . dumbBool , null )
1142
1140
assert . strictEqual ( res1 . bool , false )
1143
1141
const res2 = Serializer . decode ( {
@@ -1181,7 +1179,6 @@ suite('serializer', function () {
1181
1179
strictExtensions : true ,
1182
1180
} ) as any
1183
1181
assert . strictEqual ( res5 . bool , true )
1184
-
1185
1182
abi . structs [ 1 ] . fields [ 1 ] . type = 'many_extensions$'
1186
1183
assert . throws ( ( ) => {
1187
1184
Serializer . decode ( {
@@ -1193,6 +1190,38 @@ suite('serializer', function () {
1193
1190
} , / C i r c u l a r t y p e r e f e r e n c e / )
1194
1191
} )
1195
1192
1193
+ test ( 'optional shouldnt return null' , function ( ) {
1194
+ @Struct . type ( 'permission_level' )
1195
+ class permission_level extends Struct {
1196
+ @Struct . field ( Name )
1197
+ actor ! : Name
1198
+ @Struct . field ( Name )
1199
+ permission ! : Name
1200
+ }
1201
+
1202
+ @Struct . type ( 'approve' )
1203
+ class approve extends Struct {
1204
+ @Struct . field ( Name )
1205
+ proposer ! : Name
1206
+ @Struct . field ( Name )
1207
+ proposal_name ! : Name
1208
+ @Struct . field ( permission_level )
1209
+ level ! : permission_level
1210
+ @Struct . field ( Checksum256 , { optional : true } )
1211
+ proposal_hash ?: Checksum256
1212
+ }
1213
+ const res1 = Serializer . decode ( {
1214
+ object : {
1215
+ proposer : 'foo' ,
1216
+ proposal_name : 'bar' ,
1217
+ level : { actor : 'foo' , permission : 'bar' } ,
1218
+ } ,
1219
+ type : approve ,
1220
+ strictExtensions : true ,
1221
+ } )
1222
+ assert . notProperty ( Serializer . objectify ( res1 ) , 'proposal_hash' )
1223
+ } )
1224
+
1196
1225
test ( 'action_results' , function ( ) {
1197
1226
const raw = {
1198
1227
____comment : 'This file was generated with eosio-abigen. DO NOT EDIT ' ,
0 commit comments