Skip to content

Commit

Permalink
WLT-658 - GetPublicKey For NCW
Browse files Browse the repository at this point in the history
  • Loading branch information
goweiss committed Oct 7, 2024
1 parent fb78f01 commit aade8d4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/common/public_key_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ export async function getPublicKeyInfoImpl(peerType: PeerType, args: PublicKeyIn
let requestOptions: RequestOptions;
if (peerType === PeerType.VAULT_ACCOUNT) {
url = `/v1/vault/public_key_info`;
} else {
} else if (peerType === PeerType.END_USER_WALLET) {
requestOptions = { ncw: { walletId } };
url = `/v1/ncw/${walletId}/public_key_info`;
} else {
throw new Error(`Unsupported peer type: ${peerType}`);
}

const query = queryString.stringify({
Expand All @@ -27,9 +29,11 @@ export async function getPublicKeyInfoByAccountAssetImpl(peerType: PeerType, arg
let requestOptions: RequestOptions;
if (peerType === PeerType.VAULT_ACCOUNT) {
url = `/v1/vault/accounts/${(args as PublicKeyInfoForVaultAccountArgs).vaultAccountId}/${args.assetId}/${args.change}/${args.addressIndex}/public_key_info`;
} else {
} else if (peerType === PeerType.END_USER_WALLET) {
requestOptions = { ncw: { walletId } };
url = `/v1/ncw/${walletId}/accounts/${(args as PublicKeyInfoByAccountAssetArgs).accountId}/${args.assetId}/${args.change}/${args.addressIndex}/public_key_info`;
} else {
throw new Error(`Unsupported peer type: ${peerType}`);
}

const query = queryString.stringify({
Expand Down
10 changes: 6 additions & 4 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1219,16 +1219,18 @@ export interface PublicKeyInfoArgs {
compressed?: boolean;
}

export interface PublicKeyInfoByAccountAssetArgs {
export interface BasePublicKeyInfoByAccountAssetArgs {
assetId: string;
accountId: number;
change: number;
addressIndex: number;
compressed?: boolean;
}

export interface PublicKeyInfoForVaultAccountArgs
extends Omit<PublicKeyInfoByAccountAssetArgs, "accountId"> {
export interface PublicKeyInfoByAccountAssetArgs extends BasePublicKeyInfoByAccountAssetArgs {
accountId: number;
}

export interface PublicKeyInfoForVaultAccountArgs extends BasePublicKeyInfoByAccountAssetArgs {
vaultAccountId: number;
}

Expand Down

0 comments on commit aade8d4

Please sign in to comment.