Skip to content

Commit

Permalink
fix(sdk): Fix Moonbeam & Moonriver transfer 🔧
Browse files Browse the repository at this point in the history
Fix Interlay balance querying

Fix playground custom currency input
  • Loading branch information
michaeldev5 authored and dudo50 committed Nov 24, 2024
1 parent a97b990 commit f5343f3
Show file tree
Hide file tree
Showing 13 changed files with 1,048 additions and 260 deletions.
6 changes: 6 additions & 0 deletions apps/playground/src/components/CurrencySelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ const CurrencySelection: FC<Props> = ({ form, currencyOptions }) => {

const isNotParaToPara = isRelayToPara || isParaToRelay;

useEffect(() => {
if (isNotParaToPara) {
form.setFieldValue("isCustomCurrency", false);
}
}, [isNotParaToPara]);

return (
<Stack gap="xs">
{form.values.isCustomCurrency &&
Expand Down
18 changes: 17 additions & 1 deletion packages/sdk/scripts/assets/fetchOtherAssetsRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const capitalizeKeys = (obj: any, depth: number = 1): any => {
const newObj: any = {}
for (const key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
const value = obj[key]
let value = obj[key]
const isLeafNode = typeof value !== 'object' || value === null

let capitalizedKey: string
Expand All @@ -77,6 +77,22 @@ export const capitalizeKeys = (obj: any, depth: number = 1): any => {
capitalizedKey = key
}

if (key === 'generalKey' && typeof value === 'string') {
let data = value
const hexString = data.startsWith('0x') ? data.slice(2) : data
const byteLength = hexString.length / 2 // Each byte is two hex characters

// Pad hexString with trailing zeros to make it 32 bytes (64 hex characters)
const paddedHexString = hexString.padEnd(64, '0') // 64 hex chars = 32 bytes
data = '0x' + paddedHexString

value = {
length: byteLength,
data: data
}
}

// Recursively process nested objects
newObj[capitalizedKey] = capitalizeKeys(value, depth + 1)
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/scripts/scriptUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const fetchWithTimeout = async <T>(
): Promise<T | null> => {
const TIMEOUT_MS = 10000
try {
return new Promise<T>((resolve, reject) => {
return await new Promise<T>((resolve, reject) => {
const wsProvider = new WsProvider(wsUrl)

const timeoutHandle = setTimeout(() => {
Expand Down
Loading

0 comments on commit f5343f3

Please sign in to comment.