-
Notifications
You must be signed in to change notification settings - Fork 2
refactor: use centrifugeId instead of chainId in most places
#298
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
base: main
Are you sure you want to change the base?
Conversation
|
Auto-bumped version for release, this cannot be the last commit as bots can't trigger the workflows to pass the PR checks |
… into centrifuge-id-param
centrifugeId as input param primarilycentrifugeId instead of chainId in most places
src/Centrifuge.ts
Outdated
|
|
||
| #clients = new Map<number, Client>() | ||
| getClient(chainId: number): Client { | ||
| getClient(centrifugeId: CentrifugeId): Client { |
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.
May be cleaner to turn this into a Query and use it with combineLatest wherever it's needed
src/Centrifuge.ts
Outdated
| return this._query(['balance', currency, owner, chainId], () => { | ||
| return this.currency(currency, chainId).pipe( | ||
| return this._query(['balance', currency, owner, centrifugeId], () => { | ||
| return this.currency(currency, centrifugeId).pipe( |
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.
return combineLatest([
this.currency(currency, centrifugeId),
this._idToChain(centrifugeId)
]).pipe(...)
| makeThenable($tx, true) | ||
| Object.assign($tx, { | ||
| chainId, | ||
| chainId: resolvedChainId, |
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 should be changed to centrifugeId, as it needs to be known before transact runs. it's only used in _experimental_batch
| return this._query(['balanceSheet', chainId], () => | ||
| balanceSheet(centrifugeId: CentrifugeId) { | ||
| return this._query(['balanceSheet', centrifugeId], () => | ||
| this.pool.activeNetworks().pipe( |
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.
combineLatest([
this.pool.activeNetworks(),
this._root._idToChain(centrifugeId)
]).pipe(...)
src/entities/ShareClass.ts
Outdated
| switchMap((networks) => | ||
| this._root._idToChain(centrifugeId).pipe( | ||
| map((chainId) => { | ||
| const network = networks.find((n) => n.chainId === chainId) |
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.
No need for this._root._idToChain(centrifugeId), can check n.centrifugeId === centrifugeId
src/entities/ShareClass.ts
Outdated
| this._restrictionManager(network.chainId).pipe(catchError(() => of(null))), | ||
| of(network), | ||
| ]) | ||
| this._root.id(network.chainId).pipe( |
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 here
src/entities/ShareClass.ts
Outdated
| return this._query(['investmentsByVault', centrifugeId], () => | ||
| this._root._idToChain(centrifugeId).pipe( | ||
| switchMap((chainId) => | ||
| combineLatest([this._investorOrders(), this.vaults(chainId), this.pendingAmounts()]).pipe( |
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.
Looks like vaults() is still using chainId
src/entities/PoolNetwork.ts
Outdated
| public pool: Pool, | ||
| public chainId: number | ||
| ) { | ||
| super(_root, ['poolnetwork', pool.id.toString(), chainId]) |
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 probably take centrifugeId as argument
src/entities/PoolNetwork.ts
Outdated
| } | ||
|
|
||
| get centrifugeId(): CentrifugeId { | ||
| return this.pool.centrifugeId |
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 should be the centrifugeId of the PoolNetwork (e.g. Spoke), not the Hub
|
Auto-bumped version for release, this cannot be the last commit as bots can't trigger the workflows to pass the PR checks |
This PR standardizes the SDK to use
centrifugeId(the protocol's internal network ID) instead ofchainId(EVM chain ID) throughout the public API, aligning with the Centrifuge protocol architecture, and preparing for support of non-EVM chains.New
CentrifugeIdtype - Type alias for network identificationCore API updates:
getClient(centrifugeId)- Now accepts centrifugeId, looks up chainId internally_transact(callback, centrifugeId)- Transaction system uses centrifugeIdcreatePool(),currency(),balance(),valuations(),restrictionHooks()- All accept centrifugeIdEntity improvements:
centrifugeIdgetters toPoolandPoolNetworkentitiesPool.network(),Pool.vault(),ShareClass.member(),ShareClass.freezeMember(),Investor.investment(), etc.ID utilities:
PoolId,ShareClassId,AssetId- Getters now returnCentrifugeIdtype_chainToId()helper for reverse lookups