Skip to content

Commit

Permalink
Fix creating pools with EVM wallets (#2396)
Browse files Browse the repository at this point in the history
  • Loading branch information
onnovisser authored Aug 22, 2024
1 parent b6f242d commit e514c6f
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions centrifuge-js/src/CentrifugeBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,11 +495,14 @@ export class CentrifugeBase {
return from(response.wait()).pipe(
map((receipt) => [response, receipt] as const),
startWith([response, null] as const),
map(([response, receipt]) => {
switchMap(([response, receipt]) => {
const $events = receipt?.blockNumber ? this.getEventsByBlockNumber(receipt.blockNumber) : of(null)
return combineLatest([of(response), of(receipt), $events])
}),
map(([response, receipt, events]) => {
const result: TransactionResult = {
data: { response, receipt: receipt ?? undefined },
// TODO: Events
events: [],
events: (events as any) ?? [],
status: receipt ? 'InBlock' : 'Broadcast',
error: receipt?.status === 0 ? new Error('failed') : undefined,
txHash: response.hash,
Expand Down Expand Up @@ -657,6 +660,16 @@ export class CentrifugeBase {
)
}

getEventsByBlockNumber(blockNumber: number) {
const $api = this.getApi()
const $hash = $api.pipe(switchMap((api) => api.rpc.chain.getBlockHash(blockNumber)))
return combineLatest([$api, $hash]).pipe(
switchMap(([api, hashByBlockNumber]) => {
return api.query.system.events.at(hashByBlockNumber)
})
)
}

getSigner() {
const { signer, signingAddress } = this.config
if (!signingAddress || ((typeof signingAddress === 'string' || !('sign' in signingAddress)) && !signer)) {
Expand Down

0 comments on commit e514c6f

Please sign in to comment.