Skip to content

Commit

Permalink
fix: fix handle api response property names
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Araujo committed Jun 29, 2023
1 parent 411e884 commit 2ecc994
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 28 deletions.
2 changes: 1 addition & 1 deletion packages/cardano-services-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
},
"devDependencies": {
"@cardano-sdk/util-dev": "workspace:~",
"@koralabs/handles-public-api-interfaces": "1.6.6",
"@koralabs/handles-public-api-interfaces": "2.4.3",
"@types/validator": "^13.7.1",
"axios-mock-adapter": "^1.20.0",
"eslint": "^7.32.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ export const toHandleResolution = ({
apiResponse: IHandle;
policyId: Cardano.PolicyId;
}): HandleResolution => ({
backgroundImage: apiResponse.background ? Asset.Uri(`ipfs://${apiResponse.background}`) : undefined,
backgroundImage: apiResponse.bg_image ? Asset.Uri(`ipfs://${apiResponse.bg_image}`) : undefined,
cardanoAddress: Cardano.PaymentAddress(apiResponse.resolved_addresses.ada),
handle: apiResponse.name,
hasDatum: apiResponse.hasDatum,
hasDatum: apiResponse.has_datum,
image: apiResponse.image ? Asset.Uri(apiResponse.image) : undefined,
policyId,
profilePic: apiResponse.profile_pic ? Asset.Uri(`ipfs://${apiResponse.profile_pic}`) : undefined
profilePic: apiResponse.pfp_image ? Asset.Uri(`ipfs://${apiResponse.pfp_image}`) : undefined
});

/**
Expand Down
41 changes: 23 additions & 18 deletions packages/cardano-services-client/test/util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Asset, Cardano, ProviderError, ProviderFailure } from '@cardano-sdk/core';
import { AxiosError, AxiosResponse } from 'axios';
import { Cardano, ProviderError, ProviderFailure } from '@cardano-sdk/core';
import { IHandle, Rarity } from '@koralabs/handles-public-api-interfaces';
import { toSerializableObject } from '@cardano-sdk/util';

export const axiosError = (bodyError = new Error('error')) => {
Expand Down Expand Up @@ -37,11 +38,14 @@ export const getWrongHandleProviderResponse = {
};

export const getAliceHandleProviderResponse = {
backgroundImage: undefined,
cardanoAddress:
'addr_test1qqk4sr4f7vtqzd2w90d5nfu3n59jhhpawyphnek2y7er02nkrezryq3ydtmkg0e7e2jvzg443h0ffzfwd09wpcxy2fuqmcnecd',
handle: 'alice',
hasDatum: false,
policyId: Cardano.PolicyId('50fdcdbfa3154db86a87e4b5697ae30d272e0bbcfa8122efd3e301cb')
image: Asset.Uri('ipfs://c8fc19c2e61bab6059bf8a466e6e754833a08a62a6c56feasd'),
policyId: Cardano.PolicyId('50fdcdbfa3154db86a87e4b5697ae30d272e0bbcfa8122efd3e301cb'),
profilePic: undefined
};

export const getBobHandleProviderResponse = {
Expand All @@ -50,50 +54,51 @@ export const getBobHandleProviderResponse = {
'addr_test1qzrljm7nskakjydxlr450ktsj08zuw6aktvgfkmmyw9semrkrezryq3ydtmkg0e7e2jvzg443h0ffzfwd09wpcxy2fuql9tk0g',
handle: 'bob',
hasDatum: false,
image: Asset.Uri('ipfs://c8fc19c2e61bab6059bf8a466e6e754833a08a62a6c56fe'),
policyId: Cardano.PolicyId('50fdcdbfa3154db86a87e4b5697ae30d272e0bbcfa8122efd3e301cb'),
profilePic: 'ipfs://zrljm7nskakjydxlr450ktsj08zuw6aktvgfkmmyw9semrkrezryq3yd'
};

export const getAliceHandleAPIResponse = {
export const getAliceHandleAPIResponse: Partial<IHandle> = {
characters: 'rljm7n/23455',
created_slot_number: 33,
default_in_wallet: 'alice_default_hndle',
hasDatum: false,
has_datum: false,
hex: '0f3abbc8fc19c2e61bab6059bf8a466e6e754833a08a62a6c56fe0e78f19d9d5',
holder_address: 'stake1uyehkck0lajq8gr28t9uxnuvgcqrc6070x3k9r8048z8y5gh6ffgw',
holder: 'stake1uyehkck0lajq8gr28t9uxnuvgcqrc6070x3k9r8048z8y5gh6ffgw',
image: 'ipfs://c8fc19c2e61bab6059bf8a466e6e754833a08a62a6c56feasd',
length: 123,
name: 'alice',
nft_image: 'c8fc19c2e61bab6059bf8a466e6e754833a08a62a6c56fe',
numeric_modifiers: '-12.9',
og: 5,
original_nft_image: 'c8fc19c2e61bab6059bf8a466e6e754833a08a62a6c56feasdfasd',
rarity: 'rare',
og_number: 5,
rarity: Rarity.rare,
resolved_addresses: {
ada: 'addr_test1qqk4sr4f7vtqzd2w90d5nfu3n59jhhpawyphnek2y7er02nkrezryq3ydtmkg0e7e2jvzg443h0ffzfwd09wpcxy2fuqmcnecd'
},
standard_image: 'ipfs://c8fc19c2e61bab6059bf8a466e6e754833a08a62a6c56feasdfasd',
updated_slot_number: 22,
utxo: 'rljm7nskakjydxlr450ktsj08zuw6aktvgfkmmyw9semrkrezryq3ydtmkg0'
};

export const getBobHandleAPIResponse = {
background: 'zrljm7nskakjydxlr450ktsj08zuw6aktvgfkmmyw9semrkrezryq3yd',
export const getBobHandleAPIResponse: Partial<IHandle> = {
bg_image: 'zrljm7nskakjydxlr450ktsj08zuw6aktvgfkmmyw9semrkrezryq3yd',
characters: 'rljm7n/23455',
created_slot_number: 33,
default_in_wallet: 'bob_default_handle',
hasDatum: false,
has_datum: false,
hex: '0f3abbc8fc19c2e61bab6059bf8a466e6e754833a08a62a6c56fe0e78f19d9d5',
holder_address: 'stake1uyehkck0lajq8gr28t9uxnuvgcqrc6070x3k9r8048z8y5gh6ffgw',
holder: 'stake1uyehkck0lajq8gr28t9uxnuvgcqrc6070x3k9r8048z8y5gh6ffgw',
image: 'ipfs://c8fc19c2e61bab6059bf8a466e6e754833a08a62a6c56fe',
length: 123,
name: 'bob',
nft_image: 'c8fc19c2e61bab6059bf8a466e6e754833a08a62a6c56fe',
numeric_modifiers: '-12.9',
og: 5,
original_nft_image: 'c8fc19c2e61bab6059bf8a466e6e754833a08a62a6c56feasdfasd',
profile_pic: 'zrljm7nskakjydxlr450ktsj08zuw6aktvgfkmmyw9semrkrezryq3yd',
rarity: 'rare',
og_number: 5,
pfp_image: 'zrljm7nskakjydxlr450ktsj08zuw6aktvgfkmmyw9semrkrezryq3yd',
rarity: Rarity.rare,
resolved_addresses: {
ada: 'addr_test1qzrljm7nskakjydxlr450ktsj08zuw6aktvgfkmmyw9semrkrezryq3ydtmkg0e7e2jvzg443h0ffzfwd09wpcxy2fuql9tk0g'
},
standard_image: 'ipfs://c8fc19c2e61bab6059bf8a466e6e754833a08a62a6c56feasdfasd',
updated_slot_number: 22,
utxo: 'rljm7nskakjydxlr450ktsj08zuw6aktvgfkmmyw9semrkrezryq3ydtmkg0'
};
1 change: 1 addition & 0 deletions packages/core/src/Provider/HandleProvider/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface HandleResolution {
hasDatum: boolean;
defaultForStakeKey?: Handle;
defaultForPaymentKey?: Handle;
image?: Asset.Uri;
backgroundImage?: Asset.Uri;
profilePic?: Asset.Uri;
resolvedAt?: Point;
Expand Down
2 changes: 1 addition & 1 deletion yarn-project.nix
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ cacheEntries = {
"@jridgewell/trace-mapping@npm:0.3.17" = { filename = "@jridgewell-trace-mapping-npm-0.3.17-57578fd48c-9d703b859c.zip"; sha512 = "9d703b859cff5cd83b7308fd457a431387db5db96bd781a63bf48e183418dd9d3d44e76b9e4ae13237f6abeeb25d739ec9215c1d5bfdd08f66f750a50074a339"; };
"@jridgewell/trace-mapping@npm:0.3.9" = { filename = "@jridgewell-trace-mapping-npm-0.3.9-91625cd7fb-d89597752f.zip"; sha512 = "d89597752fd88d3f3480845691a05a44bd21faac18e2185b6f436c3b0fd0c5a859fbbd9aaa92050c4052caf325ad3e10e2e1d1b64327517471b7d51babc0ddef"; };
"@jsdevtools/ono@npm:7.1.3" = { filename = "@jsdevtools-ono-npm-7.1.3-cb2313543b-2297fcd472.zip"; sha512 = "2297fcd472ba810bffe8519d2249171132844c7174f3a16634f9260761c8c78bc0428a4190b5b6d72d45673c13918ab9844d706c3ed4ef8f62ab11a2627a08ad"; };
"@koralabs/handles-public-api-interfaces@npm:1.6.6" = { filename = "@koralabs-handles-public-api-interfaces-npm-1.6.6-d12a5f64f4-1068792818.zip"; sha512 = "10687928187ac935089781fc616a3c10596120aed2f5be2c28852cf2d8c1b14acbb72b90243f3228ff0bc9034c99230162d48d08f5aeb657c7d4decd6c6364e2"; };
"@koralabs/handles-public-api-interfaces@npm:2.4.3" = { filename = "@koralabs-handles-public-api-interfaces-npm-2.4.3-70a64faa45-ef05767a38.zip"; sha512 = "ef05767a38e4eec096bae9c5076939ff86329ed5d6a19c2c399625fb75d4f78dcee95f0d2dd321abd08b60fedc055b425a552f2f8facd405e04b791fcdf7bc21"; };
"@ledgerhq/devices@npm:8.0.0" = { filename = "@ledgerhq-devices-npm-8.0.0-e81f779f99-467bc30c8e.zip"; sha512 = "467bc30c8e60753762e52de708d5231234be4c35e0e73e39f8a0d0c7cf795a566208de4687f491de801a0f5642b16ae7de6527813f5283e247b800066ae4c4d0"; };
"@ledgerhq/errors@npm:6.12.3" = { filename = "@ledgerhq-errors-npm-6.12.3-cc51aaa92a-3284cbc85d.zip"; sha512 = "3284cbc85dc2df24f17a6e3899eb5afdff96e63d073b5914906c45ed8f1a93c7daa1e2b847d621610a1088b63c0abb9379e6b6ca395144c2d50855a4606c1d3f"; };
"@ledgerhq/hw-transport-node-hid-noevents@npm:6.27.12" = { filename = "@ledgerhq-hw-transport-node-hid-noevents-npm-6.27.12-5a1d7a1f6d-a72b45293e.zip"; sha512 = "a72b45293e2730ad5825dd90d532907c57d72e31cd00024a89c33cd1cafc44fff995c79b0af126571b004718cf673007e7ab71ec950a369c87f49c8a0628bf9e"; };
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2340,7 +2340,7 @@ __metadata:
"@cardano-sdk/core": "workspace:~"
"@cardano-sdk/util": "workspace:~"
"@cardano-sdk/util-dev": "workspace:~"
"@koralabs/handles-public-api-interfaces": 1.6.6
"@koralabs/handles-public-api-interfaces": 2.4.3
"@types/validator": ^13.7.1
axios: ^0.27.2
axios-mock-adapter: ^1.20.0
Expand Down Expand Up @@ -3778,10 +3778,10 @@ __metadata:
languageName: node
linkType: hard

"@koralabs/handles-public-api-interfaces@npm:1.6.6":
version: 1.6.6
resolution: "@koralabs/handles-public-api-interfaces@npm:1.6.6"
checksum: 10687928187ac935089781fc616a3c10596120aed2f5be2c28852cf2d8c1b14acbb72b90243f3228ff0bc9034c99230162d48d08f5aeb657c7d4decd6c6364e2
"@koralabs/handles-public-api-interfaces@npm:2.4.3":
version: 2.4.3
resolution: "@koralabs/handles-public-api-interfaces@npm:2.4.3"
checksum: ef05767a38e4eec096bae9c5076939ff86329ed5d6a19c2c399625fb75d4f78dcee95f0d2dd321abd08b60fedc055b425a552f2f8facd405e04b791fcdf7bc21
languageName: node
linkType: hard

Expand Down

0 comments on commit 2ecc994

Please sign in to comment.