Skip to content

Commit

Permalink
fix to Melbourne
Browse files Browse the repository at this point in the history
  • Loading branch information
XY-Wang committed Nov 20, 2024
1 parent cc114c7 commit 6cf8162
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
44 changes: 22 additions & 22 deletions packages/server/src/services/agents/steward/util.spec.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
import { toMelburne } from './util.js'
import { toMelbourne } from './util.js'

describe('', () => {
it('', () => {
expect(toMelburne(undefined)).toBe('')
expect(toMelburne(null)).toBe('')
expect(toMelburne('')).toBe('')
expect(toMelburne('lol')).toBe('lol')
expect(toMelburne('loL')).toBe('loL')
expect(toMelburne(100)).toBe('100')
expect(toMelburne(200n)).toBe('200')
describe('Melbourne', () => {
it('should work with primitive types', () => {
expect(toMelbourne(undefined)).toBe('')
expect(toMelbourne(null)).toBe('')
expect(toMelbourne('')).toBe('')
expect(toMelbourne('lol')).toBe('lol')
expect(toMelbourne('loL')).toBe('loL')
expect(toMelbourne(100)).toBe('100')
expect(toMelbourne(200n)).toBe('200')
})

it('', () => {
expect(toMelburne({ hey: 'joe' })).toBe('hey:joe')
it('should work with structs', () => {
expect(toMelbourne({ hey: 'joe' })).toBe('hey:joe')
expect(
toMelburne({
toMelbourne({
type: 'ForeignAsset',
value: 6,
}),
).toBe('ForeignAsset:6')
expect(
toMelburne({
toMelbourne({
type: 'Token2',
value: 5,
}),
).toBe('Token2:5')
expect(
toMelburne({
toMelbourne({
type: 'xyz',
value: {
type: 'u4',
Expand All @@ -35,28 +35,28 @@ describe('', () => {
}),
).toBe('xyz:u4:0x01010101')
expect(
toMelburne({
toMelbourne({
type: 'xyz',
value: {
u4: '0x01010101',
},
}),
).toBe('xyz:u4:0x01010101')
expect(
toMelburne({
toMelbourne({
type: 'xyz',
value: {
u4: '0x01010101',
u8: '0x0202020202020202',
},
}),
).toBe('xyz:u4:0x01010101:u8:0x0202020202020202')
expect(toMelburne({ type: 'Native', value: { type: 'BNC', value: undefined } })).toBe('Native:BNC')
expect(toMelbourne({ type: 'Native', value: { type: 'BNC', value: undefined } })).toBe('Native:BNC')
})

it('', () => {
it('should work with multi-locations', () => {
expect(
toMelburne({
toMelbourne({
parents: 1,
interior: {
type: 'X3',
Expand All @@ -79,7 +79,7 @@ describe('', () => {
).toBe('parents:1:interior:X3:0:Parachain:1000:1:PalletInstance:50:2:GeneralIndex:23')

expect(
toMelburne({
toMelbourne({
parents: 2,
interior: {
type: 'X1',
Expand All @@ -93,7 +93,7 @@ describe('', () => {
}),
).toBe('parents:2:interior:X1:GlobalConsensus:Kusama')
expect(
toMelburne({
toMelbourne({
parents: 1,
interior: {
X2: [
Expand Down
10 changes: 5 additions & 5 deletions packages/server/src/services/agents/steward/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function paginatedResults<K, V>(iterator: AbstractIterator<LevelDB,
}
}

export function toMelburne(o: unknown): string {
export function toMelbourne(o: unknown): string {
if (o == null) {
return ''
}
Expand All @@ -49,11 +49,11 @@ export function toMelburne(o: unknown): string {
return v
}
if (k === 'value') {
return v == null ? null : toMelburne(v)
return v == null ? null : toMelbourne(v)
}
return `${k}:${toMelburne(v)}`
return `${k}:${toMelbourne(v)}`
})
.filter((p) => p !== null)
.filter(Boolean)
.join(':')
}

Expand All @@ -72,7 +72,7 @@ function normalize(assetId: AssetId) {
break
}
default:
str = toMelburne(assetId)
str = toMelbourne(assetId)
}
return str.toLowerCase()
}
Expand Down

0 comments on commit 6cf8162

Please sign in to comment.