diff --git a/contracts/v0.8/cbor/MarketCbor.sol b/contracts/v0.8/cbor/MarketCbor.sol index 7adbe0bd..f76ed0c2 100644 --- a/contracts/v0.8/cbor/MarketCbor.sol +++ b/contracts/v0.8/cbor/MarketCbor.sol @@ -130,6 +130,10 @@ library MarketCBOR { buf.startFixedArray(uint64(params.deals.length)); for (uint64 i = 0; i < params.deals.length; i++) { + bool isLabelStr = bytes(params.deals[i].proposal.label.dataStr).length > 0; + bool isLabelBts = params.deals[i].proposal.label.dataBts.length > 0; + require((!isLabelStr && isLabelBts) || (!isLabelBts && isLabelStr), "deal label must be either string or bytes"); + buf.startFixedArray(2); buf.startFixedArray(11); @@ -139,7 +143,9 @@ library MarketCBOR { buf.writeBool(params.deals[i].proposal.verified_deal); buf.writeBytes(params.deals[i].proposal.client.data); buf.writeBytes(params.deals[i].proposal.provider.data); - buf.writeString(params.deals[i].proposal.label); + + isLabelStr ? buf.writeString(params.deals[i].proposal.label.dataStr) : buf.writeBytes(params.deals[i].proposal.label.dataBts); + buf.writeInt64(params.deals[i].proposal.start_epoch); buf.writeInt64(params.deals[i].proposal.end_epoch); buf.writeBytes(params.deals[i].proposal.storage_price_per_epoch.serializeBigInt()); diff --git a/contracts/v0.8/types/CommonTypes.sol b/contracts/v0.8/types/CommonTypes.sol index 40f09457..980e10bd 100644 --- a/contracts/v0.8/types/CommonTypes.sol +++ b/contracts/v0.8/types/CommonTypes.sol @@ -64,5 +64,11 @@ library CommonTypes { bytes data; } + /// @param dataBytes deal proposal label in bytes format (it can be utf8 string or arbitray bytes string) + struct DealLabel { + bytes dataBts; + string dataStr; + } + type FilActorId is uint64; } diff --git a/contracts/v0.8/types/MarketTypes.sol b/contracts/v0.8/types/MarketTypes.sol index c29de8b3..e1086188 100644 --- a/contracts/v0.8/types/MarketTypes.sol +++ b/contracts/v0.8/types/MarketTypes.sol @@ -105,7 +105,7 @@ library MarketTypes { bool verified_deal; CommonTypes.FilAddress client; CommonTypes.FilAddress provider; - string label; + CommonTypes.DealLabel label; int64 start_epoch; int64 end_epoch; CommonTypes.BigInt storage_price_per_epoch; diff --git a/testing/tests/market.rs b/testing/tests/market.rs index dac32482..8496bcbf 100644 --- a/testing/tests/market.rs +++ b/testing/tests/market.rs @@ -457,9 +457,9 @@ fn market_tests() { method_num: EvmMethods::InvokeContract as u64, sequence: 2, params: RawBytes::new( - // [[[[["0x000181E203922020B51BCC94BB0977C984C093770289DEA4E83EF08C355145D412C6673E06152A09"], 8388608, false, ["0x0390A40613DFB06445DFC3759EC22146D66B832AFE57B4AC441E5209D154131B1540E937CB837831855553E17EEFEEEED1"], ["0x0068"], "mAXCg5AIg8YBXbFjtdBy1iZjpDYAwRSt0elGLF5GvTqulEii1VcM", 25245, 545150, ["0x01001D1BF800", false], ["0x038D7EA4C68000", false], ["0x038D7EA4C68000", false]], "0x02B7E4AD239896D5DF3491AFE01F9A6F9D5C4A1E59C16E6B386CE16797C00A1224D5ABB8EFE0EDC7B052FC0AB5772BA4DA10C064537320FEFCADA4167017508D882207B23DD457966DAF21393710A26CC5509AC079EC9A0846028B279435BD5F22" ]]] + // [[[[["0x000181E203922020B51BCC94BB0977C984C093770289DEA4E83EF08C355145D412C6673E06152A09"], 8388608, false, ["0x0390A40613DFB06445DFC3759EC22146D66B832AFE57B4AC441E5209D154131B1540E937CB837831855553E17EEFEEEED1"], ["0x0068"], ["0x", "mAXCg5AIg8YBXbFjtdBy1iZjpDYAwRSt0elGLF5GvTqulEii1VcM"], 25245, 545150, ["0x01001D1BF800", false], ["0x038D7EA4C68000", false], ["0x038D7EA4C68000", false]], "0x02B7E4AD239896D5DF3491AFE01F9A6F9D5C4A1E59C16E6B386CE16797C00A1224D5ABB8EFE0EDC7B052FC0AB5772BA4DA10C064537320FEFCADA4167017508D882207B23DD457966DAF21393710A26CC5509AC079EC9A0846028B279435BD5F22" ]]] hex::decode( - "590604D21C49F10000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000004E000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001E0000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000002C0000000000000000000000000000000000000000000000000000000000000629D000000000000000000000000000000000000000000000000000000000008517E000000000000000000000000000000000000000000000000000000000000032000000000000000000000000000000000000000000000000000000000000003A0000000000000000000000000000000000000000000000000000000000000042000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000028000181E203922020B51BCC94BB0977C984C093770289DEA4E83EF08C355145D412C6673E06152A09000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000310390A40613DFB06445DFC3759EC22146D66B832AFE57B4AC441E5209D154131B1540E937CB837831855553E17EEFEEEED100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002006800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000346D41584367354149673859425862466A7464427931695A6A704459417752537430656C474C463547765471756C4569693156634D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000601001D1BF8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007038D7EA4C6800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007038D7EA4C6800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006102B7E4AD239896D5DF3491AFE01F9A6F9D5C4A1E59C16E6B386CE16797C00A1224D5ABB8EFE0EDC7B052FC0AB5772BA4DA10C064537320FEFCADA4167017508D882207B23DD457966DAF21393710A26CC5509AC079EC9A0846028B279435BD5F2200000000000000000000000000000000000000000000000000000000000000", + "590664610F3BB100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000054000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001E0000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000002C0000000000000000000000000000000000000000000000000000000000000629D000000000000000000000000000000000000000000000000000000000008517E00000000000000000000000000000000000000000000000000000000000003800000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000048000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000028000181E203922020B51BCC94BB0977C984C093770289DEA4E83EF08C355145D412C6673E06152A09000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000310390A40613DFB06445DFC3759EC22146D66B832AFE57B4AC441E5209D154131B1540E937CB837831855553E17EEFEEEED100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002006800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000346D41584367354149673859425862466A7464427931695A6A704459417752537430656C474C463547765471756C4569693156634D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000601001D1BF8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007038D7EA4C6800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007038D7EA4C6800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006102B7E4AD239896D5DF3491AFE01F9A6F9D5C4A1E59C16E6B386CE16797C00A1224D5ABB8EFE0EDC7B052FC0AB5772BA4DA10C064537320FEFCADA4167017508D882207B23DD457966DAF21393710A26CC5509AC079EC9A0846028B279435BD5F2200000000000000000000000000000000000000000000000000000000000000", ) .unwrap(), ),