Skip to content

Commit

Permalink
Merge pull request #342 from bob-collective/feat/gateway-api-logo
Browse files Browse the repository at this point in the history
feat: return project logo from api
  • Loading branch information
gregdhill authored Sep 11, 2024
2 parents b5239fc + ee4365a commit d6e91a4
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
4 changes: 2 additions & 2 deletions sdk/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gobob/bob-sdk",
"version": "2.2.6",
"version": "2.2.7",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
Expand Down
14 changes: 11 additions & 3 deletions sdk/src/gateway/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,11 @@ export class GatewayApiClient {

const strategies: GatewayStrategy[] = await response.json();
return strategies.map((strategy) => {
const strategySlug = slugify(strategy.strategyName);
const inputToken = ADDRESS_LOOKUP[strategy.inputTokenAddress];
const outputToken = strategy.outputTokenAddress ? ADDRESS_LOOKUP[strategy.outputTokenAddress] : undefined;
return {
id: "",
id: strategySlug,
type: "deposit",
address: strategy.strategyAddress,
method: "",
Expand All @@ -291,9 +292,9 @@ export class GatewayApiClient {
},
integration: {
type: strategy.strategyType,
slug: strategy.strategyName,
slug: strategySlug,
name: strategy.strategyName,
logo: "", // TODO
logo: strategy.projectLogo || outputToken?.logoURI || "",
monetization: false,
},
inputToken: {
Expand Down Expand Up @@ -378,3 +379,10 @@ function isHexPrefixed(str: string): boolean {
function stripHexPrefix(str: string): string {
return isHexPrefixed(str) ? str.slice(2) : str;
}

function slugify(str: string): string {
return str
.toLowerCase()
.replace(/ /g, "-")
.replace(/[^\w-]+/g, "");
}
6 changes: 4 additions & 2 deletions sdk/src/gateway/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ type GatewayIntegrationType = "bridge" | "dex" | "staking" | "lending";

interface GatewayIntegration {
type: GatewayIntegrationType;
/** @example rocketpool */
/** @example pell-network-wbtc */
slug: string;
/** @example RocketPool */
/** @example Pell Network (wBTC) */
name: string;
/** Format: uri */
logo: string;
Expand Down Expand Up @@ -237,6 +237,8 @@ export interface GatewayStrategy {
strategyAddress: string;
strategyName: string;
strategyType: "staking" | "lending";
projectName: string;
projectLogo?: string;
inputTokenAddress: string;
outputTokenAddress?: string;
}
6 changes: 3 additions & 3 deletions sdk/test/gateway.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,8 @@ describe("Gateway Tests", () => {
.reply(200, [{
strategyAddress: ZeroAddress,
inputTokenAddress: SYMBOL_LOOKUP[ChainId.BOB]["tbtc"].address,
name: "",
slug: "",
type: "staking"
strategyName: "Pell Network (tBTC)",
strategyType: "staking"
}]);
nock(`${MAINNET_GATEWAY_BASE_URL}`)
.get(`/quote/${SYMBOL_LOOKUP[ChainId.BOB]["tbtc"].address}?satoshis=1000&strategy=${ZeroAddress}`)
Expand All @@ -195,6 +194,7 @@ describe("Gateway Tests", () => {
assert.lengthOf(strategies, 1);
assert.isDefined(strategies[0].inputToken);
assert.isNull(strategies[0].outputToken);
assert.equal(strategies[0].integration.slug, "pell-network-tbtc");

const strategy = strategies[0];
await gatewaySDK.getQuote({
Expand Down

0 comments on commit d6e91a4

Please sign in to comment.