@@ -69,7 +69,7 @@ Finally, build a ClientConfig or CoreClientConfig to pass to the PolywrapClient
6969
7070A complete example using all or most of the available methods.
7171
72- ``` typescript
72+ ``` typescript=
7373 // init
7474 const builder = new ClientConfigBuilder();
7575
@@ -424,6 +424,16 @@ A complete example using all or most of the available methods.
424424 addDefaults (): IClientConfigBuilder ;
425425```
426426
427+ ### addBundle
428+ ``` ts
429+ /**
430+ * Add a default configuration bundle
431+ *
432+ * @returns Promise<IClientConfigBuilder> (mutated self)
433+ */
434+ addBundle (bundle : BundleName ): IClientConfigBuilder ;
435+ ```
436+
427437### build
428438``` ts
429439 /**
@@ -437,174 +447,9 @@ A complete example using all or most of the available methods.
437447
438448## Bundles
439449
440- ### Bundle: DefaultConfig
441450``` ts
442- export const ipfsProviders: string [] = [
443- " https://ipfs.wrappers.io" ,
444- " https://ipfs.io" ,
445- ];
446-
447- interface IDefaultEmbed {
448- uri: Uri ;
449- package: IWrapPackage ;
450- source: Uri ;
451- }
452-
453- interface IDefaultEmbeds {
454- ipfsHttpClient: IDefaultEmbed ;
455- ipfsResolver: IDefaultEmbed ;
456- }
457-
458- export const embeds: IDefaultEmbeds = {
459- ipfsHttpClient: {
460- uri: Uri .from (" embed/ipfs-http-client@1.0.0" ),
461- package: ipfsHttpClient .wasmPackage ,
462- source: Uri .from (" ens/wraps.eth:ipfs-http-client@1.0.0" ),
463- },
464- ipfsResolver: {
465- uri: Uri .from (" embed/async-ipfs-uri-resolver-ext@1.0.1" ),
466- package: ipfsResolver .wasmPackage ,
467- source: Uri .from (" ens/wraps.eth:async-ipfs-uri-resolver-ext@1.0.1" ),
468- },
469- };
470-
471- type UriResolverExtBootloader = [IDefaultEmbed , IUriRedirect , ... Uri []];
472-
473- export const uriResolverExts: UriResolverExtBootloader = [
474- embeds .ipfsResolver ,
475- {
476- from: Uri .from (" ens/wraps.eth:ens-text-record-uri-resolver-ext@1.0.1" ),
477- to: Uri .from (" ipfs/QmXcHWtKkfrFmcczdMSXH7udsSyV3UJeoWzkaUqGBm1oYs" ),
478- },
479- Uri .from (" ens/wraps.eth:http-uri-resolver-ext@1.0.1" ),
480- Uri .from (" ens/wraps.eth:file-system-uri-resolver-ext@1.0.1" ),
481- Uri .from (" ens/wraps.eth:ens-uri-resolver-ext@1.0.1" ),
482- Uri .from (" ens/wraps.eth:ens-ipfs-contenthash-uri-resolver-ext@1.0.1" ),
483- ];
484-
485- interface IDefaultPlugin {
486- uri: Uri ;
487- plugin: IWrapPackage ;
488- implements: Uri [];
489- }
490-
491- interface IDefaultPlugins {
492- logger: IDefaultPlugin ;
493- http: IDefaultPlugin ;
494- fileSystem: IDefaultPlugin ;
495- concurrent: IDefaultPlugin ;
496- ethereumProviderV1: IDefaultPlugin ;
497- ethereumProviderV2: IDefaultPlugin ;
498- }
499-
500- export const plugins: IDefaultPlugins = {
501- logger: {
502- uri: Uri .from (" plugin/logger@1.0.0" ),
503- plugin: loggerPlugin ({}),
504- implements: [Uri .from (" ens/wraps.eth:logger@1.0.0" )],
505- },
506- http: {
507- uri: Uri .from (" plugin/http@1.1.0" ),
508- plugin: httpPlugin ({}),
509- implements: [
510- Uri .from (" ens/wraps.eth:http@1.1.0" ),
511- Uri .from (" ens/wraps.eth:http@1.0.0" ),
512- ],
513- },
514- fileSystem: {
515- uri: Uri .from (" plugin/file-system@1.0.0" ),
516- plugin: fileSystemPlugin ({}),
517- implements: [Uri .from (" ens/wraps.eth:file-system@1.0.0" )],
518- },
519- concurrent: {
520- uri: Uri .from (" plugin/concurrent@1.0.0" ),
521- plugin: concurrentPromisePlugin ({}),
522- implements: [Uri .from (" ens/wraps.eth:concurrent@1.0.0" )],
523- },
524- ethereumProviderV1: {
525- uri: Uri .from (" plugin/ethereum-provider@1.1.0" ),
526- plugin: EthProviderV1 .plugin ({
527- connections: new EthProviderV1 .Connections ({
528- networks: {
529- mainnet: new EthProviderV1 .Connection ({
530- provider:
531- " https://mainnet.infura.io/v3/b00b2c2cc09c487685e9fb061256d6a6" ,
532- }),
533- goerli: new EthProviderV1 .Connection ({
534- provider:
535- " https://goerli.infura.io/v3/b00b2c2cc09c487685e9fb061256d6a6" ,
536- }),
537- },
538- }),
539- }),
540- implements: [
541- Uri .from (" ens/wraps.eth:ethereum-provider@1.1.0" ),
542- Uri .from (" ens/wraps.eth:ethereum-provider@1.0.0" ),
543- ],
544- },
545- ethereumProviderV2: {
546- uri: Uri .from (" plugin/ethereum-provider@2.0.0" ),
547- plugin: EthProvider .plugin ({
548- connections: new EthProvider .Connections ({
549- networks: {
550- mainnet: new EthProvider .Connection ({
551- provider:
552- " https://mainnet.infura.io/v3/b00b2c2cc09c487685e9fb061256d6a6" ,
553- }),
554- goerli: new EthProvider .Connection ({
555- provider:
556- " https://goerli.infura.io/v3/b00b2c2cc09c487685e9fb061256d6a6" ,
557- }),
558- },
559- }),
560- }),
561- implements: [Uri .from (" ens/wraps.eth:ethereum-provider@2.0.0" )],
562- },
563- };
564-
565- export function getConfig(): BuilderConfig {
566- const builder = new ClientConfigBuilder ();
567-
568- // Add all embedded packages
569- for (const embed of Object .values (embeds )) {
570- builder .addPackage (embed .uri .uri , embed .package );
571-
572- // Add source redirect
573- builder .addRedirect (embed .source .uri , embed .uri .uri );
574-
575- // Add source implementation
576- builder .addInterfaceImplementation (embed .source .uri , embed .uri .uri );
577- }
578-
579- // Add all plugin packages
580- for (const plugin of Object .values (plugins )) {
581- builder .addPackage (plugin .uri .uri , plugin .plugin );
582-
583- // Add all interface implementations & redirects
584- for (const interfaceUri of plugin .implements ) {
585- builder .addInterfaceImplementation (interfaceUri .uri , plugin .uri .uri );
586- builder .addRedirect (interfaceUri .uri , plugin .uri .uri );
587- }
588- }
589-
590- // Add all uri-resolver-ext interface implementations
591- builder .addInterfaceImplementations (
592- ExtendableUriResolver .defaultExtInterfaceUris [0 ].uri ,
593- [
594- uriResolverExts [0 ].source .uri ,
595- uriResolverExts [1 ].from .uri ,
596- ... uriResolverExts .slice (2 ).map ((x : Uri ) => x .uri ),
597- ]
598- );
599- builder .addRedirect (uriResolverExts [1 ].from .uri , uriResolverExts [1 ].to .uri );
600-
601- // Configure the ipfs-uri-resolver provider endpoints & retry counts
602- builder .addEnv (embeds .ipfsResolver .source .uri , {
603- provider: ipfsProviders [0 ],
604- fallbackProviders: ipfsProviders .slice (1 ),
605- retries: { tryResolveUri: 2 , getFile: 2 },
606- });
451+ export type BundleName = " sys" | " web3" ;
607452
608- return builder .config ;
609- }
610453```
454+ * [ sys] ( https://www.npmjs.com/package/@polywrap/sys-config-bundle-js )
455+ * [ web3] ( https://www.npmjs.com/package/@polywrap/web3-config-bundle-js )
0 commit comments