-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
405cd0c
commit 7be0768
Showing
16 changed files
with
303 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { utils } from 'ethers'; | ||
import { DataUtils } from '../src'; | ||
import * as dotenv from 'dotenv'; | ||
import { BridgingProvider } from '../src/sdk/data'; | ||
|
||
dotenv.config(); | ||
const dataApiKey = ''; | ||
|
||
async function main(): Promise<void> { | ||
// initializating Data service... | ||
const dataService = new DataUtils(dataApiKey); | ||
|
||
const allSupportedAssets = await dataService.getSupportedAssets({}); | ||
// the default provider is Connext | ||
console.log('\x1b[33m%s\x1b[0m', `All supported assets:`, allSupportedAssets.length); | ||
|
||
const supportedAssets = await dataService.getSupportedAssets({ | ||
chainId: 1, | ||
provider: BridgingProvider.Connext, | ||
}); | ||
console.log('\x1b[33m%s\x1b[0m', `Connext supported assets per chain:`, supportedAssets.length); | ||
|
||
const quotes = await dataService.getQuotes({ | ||
fromAddress: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', | ||
toAddress: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', | ||
fromChainId: 1, | ||
toChainId: 10, | ||
fromToken: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', | ||
fromAmount: utils.parseUnits('1', 18), | ||
slippage: 0.1, | ||
provider: BridgingProvider.Connext, | ||
}); | ||
console.log('\x1b[33m%s\x1b[0m', `Connext quote transactions:`, quotes); | ||
|
||
const transactionStatus = await dataService.getTransactionStatus({ | ||
fromChainId: 100, | ||
toChainId: 56, | ||
transactionHash: '0xfc46adedf462d3fd6cdbe0214ed11c06cba20c385b9875aa4d51c60afbd9725d', | ||
provider: BridgingProvider.Connext, | ||
}); | ||
console.log('\x1b[33m%s\x1b[0m', `Connext transaction status:`, transactionStatus); | ||
} | ||
|
||
main() | ||
.catch(console.error) | ||
.finally(() => process.exit()); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,10 @@ | ||
import { BigNumberish, BytesLike } from "ethers"; | ||
|
||
export class Quote { | ||
to?: string; | ||
data?: BytesLike; | ||
value?: BigNumberish; | ||
gasLimit?: string; | ||
gasPrice?: string; | ||
chainId?: number; | ||
} |
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,8 @@ | ||
export class Token { | ||
symbol: string; | ||
address: string; | ||
decimals: number; | ||
chainId: number; | ||
name: string; | ||
icon: string; | ||
} |
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,6 @@ | ||
export class TransactionStatus { | ||
status: string; | ||
transactionHash?: string; | ||
connextscanUrl: string; | ||
transferId?: string; | ||
} |
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
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,29 @@ | ||
import { BigNumberish } from 'ethers'; | ||
import { IsAddress, IsBigNumberish } from './validators'; | ||
import { IsOptional } from 'class-validator'; | ||
import { BridgingProvider } from '../data'; | ||
|
||
export class GetQuotesDto { | ||
@IsAddress() | ||
fromAddress: string; | ||
|
||
@IsAddress() | ||
toAddress: string; | ||
|
||
fromChainId: number; | ||
|
||
toChainId: number; | ||
|
||
@IsAddress() | ||
fromToken: string; | ||
|
||
@IsBigNumberish({ | ||
positive: true, | ||
}) | ||
fromAmount: BigNumberish; | ||
|
||
slippage: number; | ||
|
||
@IsOptional() | ||
provider?: BridgingProvider; | ||
} |
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,12 @@ | ||
import { IsInt, IsOptional, IsPositive } from 'class-validator'; | ||
import { BridgingProvider } from '../data'; | ||
|
||
export class GetSupportedAssetsDto { | ||
@IsOptional() | ||
@IsPositive() | ||
@IsInt() | ||
chainId?: number = null; | ||
|
||
@IsOptional() | ||
provider?: BridgingProvider; | ||
} |
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,19 @@ | ||
import { IsInt, IsOptional, IsPositive } from 'class-validator'; | ||
import { IsHex32 } from './validators'; | ||
import { BridgingProvider } from '../data'; | ||
|
||
export class GetTransactionStatusDto { | ||
@IsPositive() | ||
@IsInt() | ||
fromChainId: number; | ||
|
||
@IsPositive() | ||
@IsInt() | ||
toChainId: number; | ||
|
||
@IsHex32() | ||
transactionHash: string; | ||
|
||
@IsOptional() | ||
provider?: BridgingProvider; | ||
} |
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