private static List <NftFieldSchema> LoadSchema(ulong collectionId, Collection collection) { var schema = NftCollectionSchema.TryLoad(collectionId); return(schema?.Fields ?? new List <NftFieldSchema>() { new NftFieldSchema("Field", (int)collection.CustomDataSize) }); }
public void Create() { if (_savingInProgress) { return; } _savingInProgress = true; foreach (var validator in AllValidators()) { validator.Validate(); } if (AllValidators().SelectMany(v => v.ValidationErrors).Any()) { return; } var size = (uint)CustomDataSize(); var address = GameSettings.Address; var publicKey = AddressUtils.GetPublicKeyFromAddr(address); var fieldsSchema = _fieldScripts .Select(f => new NftFieldSchema(f.FieldName, f.FieldSize ?? 0)) .ToList(); void Cleanup() { NftClient.CollectionManagement.CollectionCreated -= Handler; _updateQueue.Enqueue(() => onCloseCollection?.Invoke()); _savingInProgress = false; } void Handler(object sender, Created created) { if (publicKey.Bytes.SequenceEqual(created.Account.Bytes)) { var schema = new NftCollectionSchema(fieldsSchema, created.Id); schema.Save(); Cleanup(); } } NftClient.CollectionManagement.CollectionCreated += Handler; var createCollection = new CreateCollection(nameField.text, descriptionField.text, tokenPrefixField.text, new CollectionMode(new Nft(size))); NftClient.CollectionManagement.CreateCollection(createCollection, new Address(address), GameSettings.PrivateKey); }