Each contract exposes a version() -> u32 function. Bump this value whenever a storage key or struct layout changes in a breaking way.
| Contract | Current Version |
|---|---|
PaymentProcessor |
1 |
RefundManager |
1 |
FXOracle |
1 |
PaymentLinkManager |
1 |
MerchantRegistry |
1 |
Storage keys (DataKey):
Payment(String)→PaymentChargeMerchantPayments(Address)→Vec<String>MerchantRateLimit(Address)→MerchantCreateRateLimitRefund(String)→RefundPaymentRefunds(String)→Vec<String>RefundCounter→u64Dispute(String)→DisputePaymentDisputes(String)→Vec<String>DisputeCounter→u64UsdcToken→AddressPaused→boolMerchantRegistryAddress→Address
Oracle keys (OracleDataKey):
Rate(Symbol)→RateData(persistent)StalenessThreshold→u64(instance)
Link keys (LinkDataKey):
Link(String)→PaymentLink
Merchant keys (MerchantDataKey):
Admin→AddressMerchant(Address)→MerchantMerchantList→Vec<Address>
Events (topic tuple → data):
(PAYMENT, CREATED, payment_id)→(merchant_id, amount)(PAYMENT, VERIFIED, payment_id)→(merchant_id, amount, amount_received)(PAYMENT, OVERPAID, payment_id)→(merchant_id, amount, amount_received)(PAYMENT, PARTIALLY_PAID, payment_id)→(merchant_id, amount, amount_received)(PAYMENT, CANCELLED, payment_id)→(merchant_id, amount)(PAYMENT, EXPIRED, payment_id)→(merchant_id, amount)(PAYMENT, SETTLED, payment_id)→(merchant_id, amount)(REFUND, CREATED)→(payment_id, refund_id, amount)(REFUND, COMPLETED)→(payment_id, refund_id, amount)(REFUND, REJECTED)→(payment_id, refund_id, amount)(DISPUTE, OPENED)→(payment_id, dispute_id, amount)(DISPUTE, UNDER_REVIEW)→(payment_id, dispute_id, amount)(DISPUTE, RESOLVED)→(payment_id, dispute_id, amount)(DISPUTE, REJECTED)→(payment_id, dispute_id, amount)(CONTRACT, PAUSED)→admin(CONTRACT, UNPAUSED)→admin(RATE, UPDATED)→pair(LINK, CREATED)→(link_id, merchant)(LINK, USED)→(link_id, payer, amount, payment_id)(LINK, DEACTIVATED)→link_id
When deploying a new contract version:
- Read old state — call
get_payment,get_refund, etc. on the live contract and confirm structs deserialise correctly with the new code before upgrading. - Bump
version()— increment the constant in the relevantimplblock. - Migrate if needed — if a
#[contracttype]struct gains or loses fields, write a one-shot migration entry-point that reads the old layout and rewrites under the new key/struct before the upgrade goes live. - Update this file — add a new
## v<N>section documenting every changed key, struct field, or event signature. - Test — run
cargo test --all-featuresand the bounded property tests locally before opening a PR.