@@ -81,7 +81,31 @@ export abstract class Setup extends SetupClient {
8181 chain? : sdk .Chain ;
8282 rootKeyHex? : string ;
8383 privKeyHex? : string ;
84- }): Promise <SetupWallet >
84+ }): Promise <SetupWallet > {
85+ const wo = await Setup .createWalletOnly ({
86+ chain: args .chain ,
87+ rootKeyHex: args .rootKeyHex ,
88+ privKeyHex: args .privKeyHex
89+ });
90+ const activeStorage = new StorageKnex ({
91+ chain: wo .chain ,
92+ knex: args .knex ,
93+ commissionSatoshis: 0 ,
94+ commissionPubKeyHex: undefined ,
95+ feeModel: { model: " sat/kb" , value: 1 }
96+ });
97+ await activeStorage .migrate (args .databaseName , wo .identityKey );
98+ await activeStorage .makeAvailable ();
99+ await wo .storage .addWalletStorageProvider (activeStorage );
100+ const { user, isNew } = await activeStorage .findOrInsertUser (wo .identityKey );
101+ const userId = user .userId ;
102+ const r: SetupWallet = {
103+ ... wo ,
104+ activeStorage ,
105+ userId
106+ };
107+ return r ;
108+ }
85109 static createSQLiteKnex(filename : string ): Knex
86110 static createMySQLKnex(connection : string , database ? : string ): Knex
87111 static async createMySQLWallet(args : {
@@ -100,7 +124,7 @@ export abstract class Setup extends SetupClient {
100124}
101125```
102126
103- See also: [ Chain] ( #type-chain ) , [ SetupClient] ( #class-setupclient ) , [ SetupWallet] ( #interface-setupwallet )
127+ See also: [ Chain] ( #type-chain ) , [ SetupClient] ( #class-setupclient ) , [ SetupWallet] ( #interface-setupwallet ) , [ StorageKnex ] ( #class-storageknex )
104128
105129<details >
106130
@@ -117,9 +141,44 @@ static async createKnexWallet(args: {
117141 chain ?: sdk .Chain ;
118142 rootKeyHex ?: string ;
119143 privKeyHex ?: string ;
120- }): Promise < SetupWallet >
144+ }): Promise < SetupWallet > {
145+ const wo = await Setup .createWalletOnly ({
146+ chain: args .chain ,
147+ rootKeyHex: args .rootKeyHex ,
148+ privKeyHex: args .privKeyHex
149+ });
150+ const activeStorage = new StorageKnex ({
151+ chain: wo .chain ,
152+ knex: args .knex ,
153+ commissionSatoshis: 0 ,
154+ commissionPubKeyHex: undefined ,
155+ feeModel: { model: " sat/kb" , value: 1 }
156+ });
157+ await activeStorage.migrate(args.databaseName , wo.identityKey);
158+ await activeStorage.makeAvailable();
159+ await wo.storage.addWalletStorageProvider(activeStorage);
160+ const { user , isNew } = await activeStorage.findOrInsertUser(wo.identityKey);
161+ const userId = user .userId ;
162+ const r: SetupWallet = {
163+ ... wo ,
164+ activeStorage ,
165+ userId
166+ };
167+ return r ;
168+ }
121169```
122- See also: [ Chain] ( #type-chain ) , [ SetupWallet] ( #interface-setupwallet )
170+ See also: [ Chain] ( #type-chain ) , [ Setup] ( #class-setup ) , [ SetupWallet] ( #interface-setupwallet ) , [ StorageKnex] ( #class-storageknex )
171+
172+ Argument Details
173+
174+ + ** args.knex**
175+ + ` Knex ` object configured for either MySQL or SQLite database access.
176+ Schema will be created and migrated as needed.
177+ For MySQL, a schema corresponding to databaseName must exist with full access permissions.
178+ + ** args.databaseName**
179+ + Name for this storage. For MySQL, the schema name within the MySQL instance.
180+ + ** args.chain**
181+ + Which chain this wallet is on: 'main' or 'test'. Defaults to 'test'.
123182
124183</details >
125184
@@ -135,7 +194,7 @@ It serves as a starting point for experimentation and customization.
135194
136195``` ts
137196export abstract class SetupClient {
138- static makeEnv(chain : sdk . Chain ): void {
197+ static makeEnv(): void {
139198 const testPrivKey1 = PrivateKey .fromRandom ();
140199 const testIdentityKey1 = testPrivKey1 .toPublicKey ().toString ();
141200 const testPrivKey2 = PrivateKey .fromRandom ();
@@ -195,6 +254,24 @@ export abstract class SetupClient {
195254
196255See also: [ Chain] ( #type-chain ) , [ KeyPairAddress] ( #type-keypairaddress ) , [ SetupWalletOnly] ( #interface-setupwalletonly ) , [ WalletStorageProvider] ( #interface-walletstorageprovider )
197256
257+ <details >
258+
259+ <summary >Class SetupClient Details</summary >
260+
261+ #### Method makeEnv
262+
263+ Create content for .env file with some private keys, identity keys, sample API keys, and sample MySQL connection string.
264+
265+ Private keys should never be included directly in you source code.
266+
267+ Loading them from a .env file is intended only for experimentation and getting started.
268+
269+ ``` ts
270+ static makeEnv (): void
271+ ```
272+
273+ </details >
274+
198275Links: [ API] ( #api ) , [ Interfaces] ( #interfaces ) , [ Classes] ( #classes ) , [ Functions] ( #functions ) , [ Types] ( #types ) , [ Variables] ( #variables )
199276
200277---
0 commit comments