Skip to content

Commit

Permalink
✨ Add eth provider in authcore
Browse files Browse the repository at this point in the history
  • Loading branch information
williamchong committed Dec 12, 2024
1 parent 2a6481f commit 1ffa101
Show file tree
Hide file tree
Showing 3 changed files with 245 additions and 95 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@
"typescript": "^4.7.4"
},
"dependencies": {
"@cosmjs/proto-signing": "^0.30.1",
"@cosmjs/proto-signing": "^0.28.13",
"@headlessui/react": "1.7.11",
"@leapwallet/cosmos-snap-provider": "^0.1.24",
"@likecoin/authcore-js": "0.3.0-like.1",
"@likecoin/secretd-js": "^0.4.5",
"@likecoin/secretd-js": "^0.5.0-beta.0",
"@walletconnect/browser-utils": "^1.8.0",
"@walletconnect/modal": "^2.4.5",
"@walletconnect/sign-client": "^2.8.0",
Expand Down
15 changes: 11 additions & 4 deletions src/utils/authcore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
import { SignDoc } from 'cosmjs-types/cosmos/tx/v1beta1/tx';
import {
AuthcoreCosmosProvider,
AuthcoreEthereumProvider,
AuthcoreVaultClient,
} from '@likecoin/secretd-js';
import { AuthCoreAuthClient, AuthCoreWidgets } from '@likecoin/authcore-js';
Expand All @@ -20,6 +21,7 @@ import {
import { convertAddressPrefix } from './wallet';

let cosmosProvider: any | null = null;
let ethereumProvider: any | null = null;
let keyVaultClient: any | null = null;

export async function initAuthcore(
Expand All @@ -42,9 +44,14 @@ export async function initAuthcore(
apiBaseURL: authcoreApiHost,
accessToken,
});
cosmosProvider = await new AuthcoreCosmosProvider({
client: keyVaultClient,
});
[cosmosProvider, ethereumProvider] = await Promise.all([
new AuthcoreCosmosProvider({
client: keyVaultClient,
}),
new AuthcoreEthereumProvider({
client: keyVaultClient,
}),
]);
const addresses = await cosmosProvider.getAddresses();
accounts = addresses.map((address: string) => {
const likeAddress = convertAddressPrefix(address);
Expand Down Expand Up @@ -105,7 +112,7 @@ export async function initAuthcore(
return {
accounts,
offlineSigner,
params: { accessToken },
params: { accessToken, cosmosProvider, ethereumProvider },
};
}

Expand Down
Loading

0 comments on commit 1ffa101

Please sign in to comment.