Skip to content

Commit

Permalink
[wallet-ext] Fix displaying publish transactions (MystenLabs#10399)
Browse files Browse the repository at this point in the history
## Description 

Fixes the `publish` transaction on wallet so that we correctly show the
bytes instead of failing.

## Test Plan 

With my hands.
  • Loading branch information
Jordan-Mysten authored Apr 5, 2023
1 parent bb06515 commit 1bc1139
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
type TransactionType,
normalizeSuiAddress,
type MakeMoveVecTransaction,
type PublishTransaction,
toB64,
} from '@mysten/sui.js';
import { useState } from 'react';

Expand All @@ -16,24 +18,32 @@ import { Text } from '_src/ui/app/shared/text';
function convertCommandArgumentToString(
arg:
| string
| number
| string[]
| number[]
| TransactionArgument
| TransactionArgument[]
| MakeMoveVecTransaction['type']
| PublishTransaction['modules']
): string | null {
if (!arg) return null;

if (typeof arg === 'string') return arg;
if (typeof arg === 'string' || typeof arg === 'number') return String(arg);

if ('None' in arg) {
if (typeof arg === 'object' && 'None' in arg) {
return null;
}

if ('Some' in arg) {
if (typeof arg === 'object' && 'Some' in arg) {
return arg.Some;
}

if (Array.isArray(arg)) {
// Publish transaction special casing:
if (typeof arg[0] === 'number') {
return toB64(new Uint8Array(arg as number[]));
}

return `[${arg
.map((argVal) => convertCommandArgumentToString(argVal))
.join(', ')}]`;
Expand Down

0 comments on commit 1bc1139

Please sign in to comment.