Assume there's a contract written in near-sdk-rs, deployed, has state defined as:
#[near_bindgen]
#[derive(BorshDeserialize, BorshSerialize)]
pub struct NFT {
pub tokens: UnorderedMap<TokenId, Token>,
}
#[derive(BorshDeserialize, BorshSerialize)]
pub struct Token {
pub owner: AccountId
}
Now there're some usage of this contract, as a result some records of tokens
stored on chain.
Then I'd like to update this contract by adding a field to Token
:
pub struct Token {
pub owner: AccountId
pub name: String // For existing ones, this will be set to ""
}
How to do this with existing state kept (similar of doing a database migration)?