-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Token minimum deposit + versions on protocol page (#192)
* Token minimum deposit * protocol version in protocol page --------- Co-authored-by: 0xdavinchee <[email protected]>
- Loading branch information
1 parent
e2ff7b6
commit f46fa37
Showing
5 changed files
with
138 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Address } from "@superfluid-finance/sdk-core"; | ||
import { | ||
RpcEndpointBuilder, | ||
getFramework, | ||
} from "@superfluid-finance/sdk-redux"; | ||
|
||
export const adhocRpcEndpoints = { | ||
endpoints: (builder: RpcEndpointBuilder) => ({ | ||
minimumDeposit: builder.query< | ||
string, | ||
{ tokenAddress: Address; chainId: number } | ||
>({ | ||
queryFn: async ({ tokenAddress, chainId }) => { | ||
const framework = await getFramework(chainId); | ||
|
||
const minimumDeposit = await framework.governance.getMinimumDeposit({ | ||
token: tokenAddress, | ||
providerOrSigner: framework.settings.provider, | ||
}); | ||
|
||
return { | ||
data: minimumDeposit, | ||
}; | ||
}, | ||
providesTags: (_result, _error, arg) => [ | ||
{ | ||
type: "GENERAL", | ||
id: arg.chainId, // TODO(KK): Could be made more specific. | ||
}, | ||
], | ||
}), | ||
protocolVersion: builder.query<string, { chainId: number }>({ | ||
queryFn: async ({ chainId }) => { | ||
const framework = await getFramework(chainId); | ||
|
||
const protocolVersion = await framework.contracts.resolver | ||
.connect(framework.settings.provider) | ||
.get("versionString.v1"); | ||
|
||
return { | ||
data: protocolVersion, | ||
}; | ||
}, | ||
providesTags: (_result, _error, arg) => [ | ||
{ | ||
type: "GENERAL", | ||
id: arg.chainId, // TODO(KK): Could be made more specific. | ||
}, | ||
], | ||
}), | ||
}), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Takes a `pseudoAddress` and returns the `versionString`. | ||
* @param pseudoAddress format: 0x000000000000000000${major}${minor}${patch}${gitRevision} | ||
* @returns `versionString` with format: major.minor.patch-rrrrrrrrrrrrrrrr, r: 16-digit git revision (hex) | ||
*/ | ||
export function pseudoAddressToVersionString(pseudoAddress: string) { | ||
const str = pseudoAddress.replace(/^0x/, "").toLowerCase(); // remove leading 0x | ||
const major = parseInt(str.slice(18, 20), 10); | ||
const minor = parseInt(str.slice(20, 22), 10); | ||
const patch = parseInt(str.slice(22, 24), 10); | ||
const revision = str.slice(24); | ||
|
||
if ( | ||
!str.startsWith("000000000000000000") || | ||
isNaN(major) || | ||
isNaN(minor) || | ||
isNaN(patch) | ||
) { | ||
return undefined; | ||
} | ||
|
||
return `${major}.${minor}.${patch}-${revision}`; | ||
} |
f46fa37
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
superfluid-console – ./
superfluid-console-superfluid-finance.vercel.app
superfluid-console-git-master-superfluid-finance.vercel.app
console.superfluid.finance
explorer.superfluid.finance