Update IDX dependencies

Signed-off-by: Sebastian Martinez <sebastinez@me.com>
This commit is contained in:
Sebastian Martinez
2021-10-30 22:43:05 +02:00
parent 53365e18f3
commit 1f5193b032
5 changed files with 1062 additions and 183 deletions
+3 -7
View File
@@ -3,8 +3,7 @@ import type { Writable } from "svelte/store";
import { ethers } from "ethers";
import type { TypedDataSigner } from '@ethersproject/abstract-signer';
import SafeServiceClient from "@gnosis.pm/safe-service-client";
import CeramicClient from "@ceramicnetwork/http-client";
import { IDX } from "@ceramicstudio/idx";
import { Core } from '@self.id/core';
import WalletConnect from "@walletconnect/client";
import config from "@app/config.json";
import { WalletConnectSigner } from "./WalletConnectSigner";
@@ -62,9 +61,8 @@ export class Config {
api: { port: number };
link: { port: number };
};
idx: { client: IDX };
ceramic: {
client: CeramicClient;
client: Core;
registry: string;
};
tokens: string[];
@@ -76,8 +74,7 @@ export class Config {
metamaskSigner: ethers.Signer & TypedDataSigner | null,
) {
const cfg = (<Record<string, any>> config)[network.name];
const ceramic = new CeramicClient(config.ceramic.api);
const idx = new IDX({ ceramic });
const ceramic = new Core({ ceramic: config.ceramic.api });
const walletConnectState = writable<WalletConnectState>(
{ state: "close" }
@@ -120,7 +117,6 @@ export class Config {
this.signer = null;
this.gasLimits = gasLimits;
this.abi = config.abi;
this.idx = { client: idx };
this.ceramic = {
client: ceramic,
registry: config.ceramic.registry
+5 -4
View File
@@ -1,6 +1,6 @@
import { AccountId } from 'caip';
import { AccountID } from 'caip';
import type { EnsProfile } from "@app/base/registrations/registrar";
import type { BasicProfile } from "@ceramicstudio/idx-constants";
import type { BasicProfile } from '@datamodels/identity-profile-basic';
import {
isAddress, formatCAIP10Address, formatIpfsFile, resolveEnsProfile, resolveIdxProfile, parseUsername, parseEnsLabel
} from "@app/utils";
@@ -90,7 +90,7 @@ export class Profile {
const addr = this.profile?.ens?.anchorsAccount;
if (addr) {
const id = new AccountId(addr);
const id = new AccountID(addr);
// Ethereum address.
if (typeof id.chainId === "object" && id.chainId.namespace === "eip155") {
@@ -145,7 +145,8 @@ export class Profile {
formatCAIP10Address(address, "eip155", config.network.chainId), config
);
return { address, ens: null, idx };
} catch {
} catch (e) {
console.error(e);
return { address, ens: null, idx: null };
}
}
+2 -2
View File
@@ -8,7 +8,7 @@ import config from "@app/config.json";
import { assert } from '@app/error';
import type { EnsProfile } from "@app/base/registrations/registrar";
import { getAvatar, getSeedHost, getSeedId, getAnchorsAccount, getRegistration } from '@app/base/registrations/registrar';
import type { BasicProfile } from "@ceramicstudio/idx-constants";
import type { BasicProfile } from '@datamodels/identity-profile-basic';
import { ProfileType } from '@app/profile';
export enum AddressType {
@@ -267,7 +267,7 @@ export async function resolveLabel(label: string | undefined, config: Config): P
// Resolves an IDX profile or return null
export async function resolveIdxProfile(caip10: string, config: Config): Promise<BasicProfile | null> {
return config.idx.client.get<BasicProfile>("basicProfile", caip10);
return config.ceramic.client.get("basicProfile", caip10);
}
// Resolves an ENS profile or return null