@learncard/core 4.0.0 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/core.d.ts CHANGED
@@ -4611,6 +4611,7 @@ export declare type DidkitPluginMethods = {
4611
4611
  verifyCredential: (credential: VC) => Promise<VerificationCheck>;
4612
4612
  issuePresentation: (presentation: UnsignedVP, options: ProofOptions, keypair: KeyPair) => Promise<VP>;
4613
4613
  verifyPresentation: (presentation: VP) => Promise<VerificationCheck>;
4614
+ contextLoader: (url: string) => Promise<Record<string, any>>;
4614
4615
  };
4615
4616
  export declare type Algorithm = "ed25519" | "secp256k1";
4616
4617
  export declare type DidKeyPluginMethods<DidMethod extends string> = {
@@ -4625,12 +4626,15 @@ export declare type DidKeyPluginMethods<DidMethod extends string> = {
4625
4626
  getKey: () => string;
4626
4627
  };
4627
4628
  export declare type EthereumPluginMethods = {
4628
- checkMyEth: () => Promise<string>;
4629
- checkMyDai: () => Promise<string>;
4630
- checkMyUsdc: () => Promise<string>;
4629
+ getEthereumAddress: () => string;
4630
+ getBalance: (symbolOrAddress?: string) => Promise<string>;
4631
+ getBalanceForAddress: (walletAddress: string, symbolOrAddress?: string) => Promise<string>;
4632
+ transferTokens: (tokenSymbolOrAddress: string, amount: number, toAddress: string) => Promise<string>;
4633
+ getCurrentNetwork: () => providers.Networkish;
4634
+ changeNetwork: (network: providers.Networkish) => void;
4635
+ addInfuraProjectId: (infuraProjectIdToAdd: string) => void;
4631
4636
  };
4632
4637
  export declare type EthereumConfig = {
4633
- address: string;
4634
4638
  infuraProjectId?: string;
4635
4639
  network?: providers.Networkish;
4636
4640
  };
@@ -4674,7 +4678,15 @@ export declare type VCPluginMethods = DependentMethods & {
4674
4678
  export declare type VerifyExtension = {
4675
4679
  verifyCredential: (credential: VC) => Promise<VerificationCheck>;
4676
4680
  };
4681
+ export declare type VpqrPluginMethods = {
4682
+ vpFromQrCode: (text: string) => Promise<VP>;
4683
+ vpToQrCode: (vp: VP) => Promise<string>;
4684
+ };
4677
4685
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
4686
+ export declare type InitFunction<Args extends Record<string, any> | undefined = Record<string, any>, Config extends keyof LearnCardConfig = keyof LearnCardConfig, ReturnValue extends LearnCard<any, any> = LearnCard<any, any>> = {
4687
+ args: undefined extends Args ? Partial<Pick<LearnCardConfig, Config>> : Args & Partial<Pick<LearnCardConfig, Config>>;
4688
+ returnValue: ReturnValue;
4689
+ };
4678
4690
  export declare type Plugin<Name extends string, PublicMethods extends Record<string, (...args: any[]) => any> = Record<never, never>> = {
4679
4691
  name?: Name;
4680
4692
  pluginMethods: {
@@ -4691,7 +4703,7 @@ export declare type Wallet<PluginNames extends string = "", PluginMethods extend
4691
4703
  remove: (contentId: string) => Promise<Wallet<PluginNames, PluginMethods>>;
4692
4704
  addPlugin: <Name extends string, Methods extends Record<string, (...args: any[]) => any> = Record<never, never>>(plugin: Plugin<Name, Methods>) => Promise<Wallet<"" extends PluginNames ? Name : PluginNames | Name, Record<never, never> extends PluginMethods ? Methods : PluginMethods & Methods>>;
4693
4705
  };
4694
- export declare type LearnCardRawWallet = Wallet<"DIDKit" | "DID Key" | "VC" | "IDX" | "Expiration" | "Ethereum", DidKeyPluginMethods<DidMethod> & VCPluginMethods & IDXPluginMethods & EthereumPluginMethods>;
4706
+ export declare type LearnCardRawWallet = Wallet<"DIDKit" | "DID Key" | "VC" | "IDX" | "Expiration" | "Ethereum" | "Vpqr", DidKeyPluginMethods<DidMethod> & VCPluginMethods & IDXPluginMethods & EthereumPluginMethods & VpqrPluginMethods>;
4695
4707
  export declare type AllLearnCardMethods = {
4696
4708
  /** Wallet holder's did */
4697
4709
  did: (type?: DidMethod) => string;
@@ -4770,17 +4782,44 @@ export declare type AllLearnCardMethods = {
4770
4782
  */
4771
4783
  getTestVp: (credential?: VC) => Promise<UnsignedVP>;
4772
4784
  /**
4773
- * Returns your ETH balance
4785
+ * Returns Ethereum public address
4786
+ */
4787
+ getEthereumAddress: () => string;
4788
+ /**
4789
+ * Get the balance of an ERC20 token
4790
+ * Defaults to ETH if symbolOrAddress is not provided
4791
+ */
4792
+ getBalance: (symbolOrAddress?: string) => Promise<string>;
4793
+ /**
4794
+ * Get the balance of an ERC20 token for a given address
4795
+ * Defaults to ETH if symbolOrAddress is not provided
4796
+ */
4797
+ getBalanceForAddress: (walletAddress: string, symbolOrAddress?: string) => Promise<string>;
4798
+ /**
4799
+ * Transfer tokens to a given address
4800
+ */
4801
+ transferTokens: (tokenSymbolOrAddress: string, amount: number, toAddress: string) => Promise<string>;
4802
+ /**
4803
+ * Get your current Ethereum network
4804
+ */
4805
+ getCurrentNetwork: () => ethers.providers.Networkish;
4806
+ /**
4807
+ * Change your Ethereum network
4808
+ */
4809
+ changeNetwork: (network: ethers.providers.Networkish) => void;
4810
+ /**
4811
+ * Add an infura project id to an existing wallet.
4812
+ * Really only useful for testing with the CLI right now...
4774
4813
  */
4775
- checkMyEth: () => Promise<string>;
4814
+ addInfuraProjectId: (infuraProjectIdToAdd: string) => void;
4776
4815
  /**
4777
- * Returns your DAI balance
4816
+ * Returns a Verifiable Presentation (VP) from a QR code base-64 image data string containing a VP compressed by CBOR-LD.
4778
4817
  */
4779
- checkMyDai: () => Promise<string>;
4818
+ vpFromQrCode: (text: string) => Promise<VP>;
4780
4819
  /**
4781
- * Returns your USDC balance
4820
+ * Returns a QR-embeddable base-64 image data string from a Verifiable Presentation, compressed using CBOR-LD.
4782
4821
  */
4783
- checkMyUsdc: () => Promise<string>;
4822
+ vpToQrCode: (vp: VP) => Promise<string>;
4784
4823
  };
4785
4824
  export declare type LearnCard<Methods extends keyof AllLearnCardMethods = keyof AllLearnCardMethods, RawWallet extends Wallet<any, any> = LearnCardRawWallet> = {
4786
4825
  /** Raw IoE wallet instance. You shouldn't need to drop down to this level! */
@@ -4799,10 +4838,16 @@ export declare type LearnCardConfig = {
4799
4838
  defaultContents: any[];
4800
4839
  ethereumConfig: EthereumConfig;
4801
4840
  };
4841
+ export declare type EmptyWallet = InitFunction<undefined, "didkit", EmptyLearnCard>;
4842
+ export declare type WalletFromKey = InitFunction<{
4843
+ seed: string;
4844
+ }, keyof LearnCardConfig, LearnCard>;
4802
4845
  /** Generates an empty wallet with no key material */
4803
- export declare const emptyWallet: ({ didkit, }?: Partial<Pick<LearnCardConfig, "didkit">>) => Promise<EmptyLearnCard>;
4846
+ export declare const emptyWallet: ({ didkit }?: EmptyWallet["args"]) => Promise<EmptyWallet["returnValue"]>;
4804
4847
  /** Generates a LearnCard Wallet from a 64 character seed string */
4805
4848
  export declare const walletFromKey: (key: string, { ceramicIdx, didkit, defaultContents, ethereumConfig, }?: Partial<LearnCardConfig>) => Promise<LearnCard>;
4849
+ export declare function initLearnCard(config?: EmptyWallet["args"]): Promise<EmptyWallet["returnValue"]>;
4850
+ export declare function initLearnCard(config: WalletFromKey["args"]): Promise<WalletFromKey["returnValue"]>;
4806
4851
  export * from "@wallet/init";
4807
4852
  export { Wallet, Plugin } from "types/wallet";
4808
4853