private async Task <CreateInboxResponseMessage> CreateInboxAsync(IAgentContext agentContext, ConnectionRecord connection, CreateInboxMessage createInboxMessage) { if (connection.State != ConnectionState.Connected) { throw new InvalidOperationException("Can't create inbox if connection is not in final state"); } string inboxId = $"Edge{Guid.NewGuid().ToString("N")}"; string inboxKey = await Wallet.GenerateWalletKeyAsync(IndySdkDefaultOptions); var inboxRecord = new InboxRecord { Id = inboxId, WalletConfiguration = new WalletConfiguration { Id = inboxId, StorageType = options.WalletConfiguration?.StorageType ?? "default", StorageConfiguration = options.WalletConfiguration?.StorageConfiguration }, WalletCredentials = new WalletCredentials { Key = inboxKey, KeyDerivationMethod = options.WalletCredentials?.KeyDerivationMethod, StorageCredentials = options.WalletCredentials?.StorageCredentials } }; connection.SetTag("InboxId", inboxId); await walletService.CreateWalletAsync( configuration : inboxRecord.WalletConfiguration, credentials : inboxRecord.WalletCredentials); if (createInboxMessage.Metadata != null) { foreach (var metadata in createInboxMessage.Metadata) { inboxRecord.SetTag(metadata.Key, metadata.Value); } } await recordService.AddAsync(agentContext.Wallet, inboxRecord); await recordService.UpdateAsync(agentContext.Wallet, connection); return(new CreateInboxResponseMessage { InboxId = inboxId, InboxKey = inboxKey }); }
private async Task <CreateInboxResponseMessage> CreateInboxAsync(IAgentContext agentContext, ConnectionRecord connection, CreateInboxMessage createInboxMessage) { if (connection.State != ConnectionState.Connected) { throw new InvalidOperationException("Can't create inbox if connection is not in final state"); } var inboxId = $"Edge{Guid.NewGuid().ToString("N")}"; var inboxKey = Guid.NewGuid().ToString(); var inboxRecord = new InboxRecord { Id = inboxId, WalletConfiguration = new WalletConfiguration { Id = inboxId, StorageType = options.WalletConfiguration?.StorageType ?? "default", StorageConfiguration = options.WalletConfiguration?.StorageConfiguration }, WalletCredentials = new WalletCredentials { Key = inboxKey, StorageCredentials = options.WalletCredentials.StorageCredentials = options.WalletConfiguration.StorageCredential } }; connection.SetTag("InboxId", inboxId); await walletService.CreateWalletAsync( configuration : inboxRecord.WalletConfiguration, credentials : inboxRecord.WalletCredentials); await recordService.AddAsync(agentContext.Wallet, inboxRecord); await recordService.UpdateAsync(agentContext.Wallet, connection); return(new CreateInboxResponseMessage { InboxId = inboxId, InboxKey = inboxKey }); }