-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: SDK POC #11
feat: SDK POC #11
Conversation
# Conflicts: # packages/sdk/src/index.ts # packages/sdk/src/types.ts
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.
I think it would make sense to intrudce custom error classes for handling errors
"https://gopher.test.buildwithsygma.com/" | ||
); | ||
export function setBaseUrl(url: string): void { | ||
BASE_URL = url; |
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.
why not set process.env instead?
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.
and you end up in vite
that does not to useprocess.env
but there is import.meta.env
, made helper method to solve this problem and the setter is in a case you have no options to provide .env
like in React you need use prefix REACT_
for env
's
packages/sdk/src/api.ts
Outdated
if (whitelistedSourceChains && whitelistedSourceChains.length) | ||
url.searchParams.set( | ||
"whitelistedSourceChains", | ||
whitelistedSourceChains.toString() |
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.
whitelistedSourceChains.toString() | |
whitelistedSourceChains.join(",") |
?
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.
it is the same result
const a = [1,2,3,4];
a.join();
// '1,2,3,4'
a.join(',');
// '1,2,3,4'
a.toString();
// '1,2,3,4'
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.
but you're using one extra character! 🤣
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.
I was going to argue it's more expressive 😂
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.
I wanted but been layz to make benchmarks.
But it is on mu super "short" TODO list for personal projects
web/src/lib/utils.ts
Outdated
const noNetworkFound: Chain = { | ||
chainID: 0, | ||
chainType: 'evm', | ||
name: 'none', | ||
logoURI: 'https://static.thenounproject.com/png/75231-200.png', | ||
rpcurls: [] | ||
}; |
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.
same as last comment, just an observation, maybe satisfies
would be more appropriate here
const noNetworkFound: Chain = { | |
chainID: 0, | |
chainType: 'evm', | |
name: 'none', | |
logoURI: 'https://static.thenounproject.com/png/75231-200.png', | |
rpcurls: [] | |
}; | |
const noNetworkFound = { | |
chainID: 0, | |
chainType: 'evm', | |
name: 'none', | |
logoURI: 'https://static.thenounproject.com/png/75231-200.png', | |
rpcurls: [] | |
} satisfies Chain; |
whitelistedSourceChains | ||
); | ||
return Promise.resolve([]); | ||
const tokenList = tokens || (await this.getAvailableTokens()); |
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.
should we getAvailableTokens
if provided tokens
array is empty too?
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.
This tricky question is like if you set an intentionally empty array (it is not logical to do) as an optional parameter and you got the result that is not part that reflects that array.
variable = env[envName]; | ||
} | ||
} finally { | ||
variable ??= defaultValue; |
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.
??=
😍
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.
packages/sdk/src/types.ts
Outdated
export type ChainID = number; | ||
|
||
export interface FungibleToken { | ||
addresses: { [chainID: ChainID]: Address }; |
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.
nit: this can also be a Record<ChainID, Address>
, but no need to update
🤖 I have created a release *beep* *boop* --- ## [0.1.0](sprinter-sdk-v0.0.1...sprinter-sdk-v0.1.0) (2024-09-12) ### Features * api options ([#33](#33)) ([ad1cb88](ad1cb88)) * cross chain contract call ([#21](#21)) ([69c0128](69c0128)) * depricate provider param from sdk ([#41](#41)) ([72297fe](72297fe)) * docs POC ([#14](#14)) ([8cd800d](8cd800d)) * erc20 with contract call ([#39](#39)) ([77e1d8d](77e1d8d)), closes [#38](#38) * native tokens transfers ([#40](#40)) ([d4edf35](d4edf35)), closes [#36](#36) * SDK POC ([#11](#11)) ([6aca865](6aca865)) * web poc (super basic basic) ([#3](#3)) ([25a91f7](25a91f7)) ### Bug Fixes * process approvals from quote ([#26](#26)) ([95d9ebf](95d9ebf)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
🤖 I have created a release *beep* *boop* --- <details><summary>sprinter-sdk: 0.3.0</summary> ## [0.3.0](sprinter-sdk-v0.2.0...sprinter-sdk-v0.3.0) (2024-09-23) ### Features * api options ([#33](#33)) ([ad1cb88](ad1cb88)) * cross chain contract call ([#21](#21)) ([69c0128](69c0128)) * depricate provider param from sdk ([#41](#41)) ([72297fe](72297fe)) * docs POC ([#14](#14)) ([8cd800d](8cd800d)) * erc20 with contract call ([#39](#39)) ([77e1d8d](77e1d8d)), closes [#38](#38) * implement tracing url resolver ([#46](#46)) ([efd1be3](efd1be3)), closes [#44](#44) * native tokens transfers ([#40](#40)) ([d4edf35](d4edf35)), closes [#36](#36) * react sdk context ([#48](#48)) ([39dbe7e](39dbe7e)), closes [#47](#47) * SDK POC ([#11](#11)) ([6aca865](6aca865)) * web poc (super basic basic) ([#3](#3)) ([25a91f7](25a91f7)) ### Bug Fixes * process approvals from quote ([#26](#26)) ([95d9ebf](95d9ebf)) </details> <details><summary>sprinter-react: 0.2.0</summary> ## [0.2.0](sprinter-react-v0.1.0...sprinter-react-v0.2.0) (2024-09-23) ### Features * react sdk context ([#48](#48)) ([39dbe7e](39dbe7e)), closes [#47](#47) ### Bug Fixes * cd and rect hooks export ([#52](#52)) ([33c0604](33c0604)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Draft, POC