Open sujitv19196 opened 4 years ago
@sujitv19196 @vaishumyadam great job you two!
Sorry for being flat voiced during our meeting. Was trying to think of suggestions that were not coming to me at the time 😅
So, the suggestion I had was to do something about the redundancy of having 3 arrays for txns.
This immediately appears too redundant. What I was thinking, instead of using a mapping
after refreshing my memory, is to use an enum
for the txn status. It would look something like this:
// Where `Pending` is the default value as the first member
enum TxnStatus { Pending, Accepted, Verified, Premature, Rejected }
struct Transaction {
string name;
string description;
string rejectedMsg;
uint256 quantity;
address currentOwner;
address recipient;
}
Each of the members in the enum TxnStatus
are numbered, where Pending = 0
, Accepted = 1
, etc.
So, changing the state of a txn would be done by changing the state in the enum
.
Then, you could wrap enums with transactions like this:
// Where `Pending` is the default value as the first member
enum TxnStatus { Pending, Accepted, Verified, Premature, Rejected }
struct TxnRecord {
TxnStatus txnStatus,
mapping (uint => Transaction) transactions
}
struct Transaction {
string name;
string description;
string rejectedMsg;
uint256 quantity;
address currentOwner;
address recipient;
}
Finally, the resulting data could look something like this:
{
// all pending transactions
txnStatus: 0,
transactions: {
0: {...},
1: {...},
2: {...},
...
},
},
{
// all accepted transactions
txnStatus: 1,
transactions: {
0: {...},
1: {...},
2: {...},
...
},
},
{
// all verified transactions
txnStatus: 2,
transactions: {
0: {...},
1: {...},
2: {...},
...
},
},
{...}
Let me know if this makes sense and what you two think. Do you both think this is implementable? Or does this complicate what you both have already?
@orangewit3 Eager to hear what you all think, as this suggestion is open for discussion.
SupplyChainTransactions:
Manufacturer and Farmer:
Carrier: