Skip to content

Commit

Permalink
Try uuid lib
Browse files Browse the repository at this point in the history
  • Loading branch information
abtestingalpha committed Jul 28, 2024
1 parent 806c12d commit ce93bc9
Show file tree
Hide file tree
Showing 7 changed files with 784 additions and 16 deletions.
2 changes: 2 additions & 0 deletions packages/sdk-router/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ If either of the input/output tokens is a native gas token (e.g. ETH on Ethereum

```ts
export type BridgeQuote = {
// UUID (v7), unique id corresponding to quote
id: string
// Address of the Router contract that user will be interacting with
routerAddress: string
// Expected final amount of tokens to be received on the destination chain by the user,
Expand Down
1 change: 1 addition & 0 deletions packages/sdk-router/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
setupFiles: ['<rootDir>/jest.setup.js'],
maxConcurrency: 1,
testTimeout: 30000,
}
7 changes: 7 additions & 0 deletions packages/sdk-router/jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
jest.mock('node:crypto', () => {
return {
...jest.requireActual('crypto'),
randomBytes: jest.fn(() => Buffer.from('mockedRandomBytes')),
// Add other crypto methods if needed
}
})
4 changes: 3 additions & 1 deletion packages/sdk-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"@ethersproject/providers": "^5.7.0",
"@types/big.js": "^4.0.5",
"@types/jest": "^24.0.25",
"@types/uuid": "^10.0.0",
"dotenv": "^16.3.1",
"husky": "^8.0.1",
"jest-fetch-mock": "^3.0.3",
Expand Down Expand Up @@ -75,6 +76,7 @@
"node-cache": "^5.1.2",
"tiny-invariant": "^1.2.0",
"toformat": "^2.0.0",
"ts-xor": "^1.1.0"
"ts-xor": "^1.1.0",
"uuid": "^10.0.0"
}
}
4 changes: 4 additions & 0 deletions packages/sdk-router/src/module/synapseModuleSet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { BigNumber } from '@ethersproject/bignumber'
import invariant from 'tiny-invariant'
import { v7 as uuidv7 } from 'uuid'

import { BigintIsh } from '../constants'
import { BridgeQuote, BridgeRoute, FeeConfig } from './types'
Expand Down Expand Up @@ -205,7 +206,10 @@ export abstract class SynapseModuleSet {
originQuery.deadline = originModuleDeadline
destQuery.deadline = destModuleDeadline
const { feeAmount, feeConfig } = await this.getFeeData(bridgeRoute)
const id = uuidv7()

return {
id,
feeAmount,
feeConfig,
routerAddress: originModule.address,
Expand Down
1 change: 1 addition & 0 deletions packages/sdk-router/src/module/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export type SwapQuote = {
* Returned by SDK to the consumer.
*/
export type BridgeQuote = {
id: string
feeAmount: BigNumber
feeConfig: FeeConfig
routerAddress: string
Expand Down
Loading

0 comments on commit ce93bc9

Please sign in to comment.