Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #185 from kodadot/bsx-untyped
Browse files Browse the repository at this point in the history
bsx untyped
  • Loading branch information
vikiival authored Aug 30, 2023
2 parents a2aac95 + d300796 commit c013822
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 2 deletions.
1 change: 1 addition & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ type AssetEntity @entity {
name: String
symbol: String
decimals: Int
deposit: BigInt
}

# Implement in the later stages
Expand Down
13 changes: 11 additions & 2 deletions src/mappings/assetRegistry/getters/basilisk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,18 @@ export function getAssetUpdateEvent(ctx: Context): AssetRegisterEvent {
};
}

const { assetId: id, assetName: name, assetType: type } = event.asV55;
if (event.isV55) {
const { assetId: id, assetName: name, assetType: type } = event.asV55;
return {
id: id.toString(), name: name.toString(), type: type.__kind, isToken: type.__kind === 'Token',
};
}

const {
assetId: id, assetName: name, assetType: type, existentialDeposit: deposit,
} = event.asV101;
return {
id: id.toString(), name: name.toString(), type: type.__kind, isToken: type.__kind === 'Token',
id: id.toString(), name: name.toString(), type: type.__kind, isToken: type.__kind === 'Token', deposit,
};
}

Expand Down
1 change: 1 addition & 0 deletions src/mappings/assetRegistry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export async function handleAssetUpdate(context: Context): Promise<void> {
}

asset.name = event.name;
asset.deposit = event.deposit;
logger.success(`[ASSET UPDATE]: by ${event.id} is ${event.name}`);
await context.store.save<AssetEntity>(asset);
}
Expand Down
1 change: 1 addition & 0 deletions src/mappings/assetRegistry/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export type AssetRegisterEvent = {
name: string;
type: string;
isToken: boolean;
deposit?: bigint;
};

export type AssetMetadata = {
Expand Down
4 changes: 4 additions & 0 deletions src/model/generated/assetEntity.model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_} from "typeorm"
import * as marshal from "./marshal"

@Entity_()
export class AssetEntity {
Expand All @@ -17,4 +18,7 @@ export class AssetEntity {

@Column_("int4", {nullable: true})
decimals!: number | undefined | null

@Column_("numeric", {transformer: marshal.bigintTransformer, nullable: true})
deposit!: bigint | undefined | null
}
16 changes: 16 additions & 0 deletions src/types/basilisk/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as v65 from './v65'
import * as v71 from './v71'
import * as v81 from './v81'
import * as v92 from './v92'
import * as v101 from './v101'

export class AssetRegistryMetadataSetEvent {
private readonly _chain: Chain
Expand Down Expand Up @@ -170,6 +171,21 @@ export class AssetRegistryUpdatedEvent {
assert(this.isV55)
return this._chain.decodeEvent(this.event)
}

/**
* Asset was updated.
*/
get isV101(): boolean {
return this._chain.getEventHash('AssetRegistry.Updated') === 'b58db9ce20bc6b9cc05e7997f4401f70f34516fea867b05b4834f83da55a29a2'
}

/**
* Asset was updated.
*/
get asV101(): {assetId: number, assetName: Uint8Array, assetType: v101.AssetType, existentialDeposit: bigint, xcmRateLimit: (bigint | undefined)} {
assert(this.isV101)
return this._chain.decodeEvent(this.event)
}
}

export class MarketplaceOfferAcceptedEvent {
Expand Down
12 changes: 12 additions & 0 deletions src/types/basilisk/v101.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type {Result, Option} from './support'

export type AssetType = AssetType_Token | AssetType_PoolShare

export interface AssetType_Token {
__kind: 'Token'
}

export interface AssetType_PoolShare {
__kind: 'PoolShare'
value: [number, number]
}

0 comments on commit c013822

Please sign in to comment.