Compare commits
6 Commits
fix/invoke
...
fix/hex-va
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dc37b1911a | ||
|
|
c348868c89 | ||
|
|
2c3cfebe3a | ||
|
|
6265a9cdbf | ||
|
|
1321b498cf | ||
|
|
801d9778cb |
@@ -57,13 +57,13 @@ const Transaction: FC<TransactionProps> = ({ header, state: txState, ...props })
|
|||||||
SetHookData['HookParameters']
|
SetHookData['HookParameters']
|
||||||
>((acc, [_, { label, value }]) => {
|
>((acc, [_, { label, value }]) => {
|
||||||
return acc.concat({
|
return acc.concat({
|
||||||
HookParameter: { HookParameterName: toHex(label), HookParameterValue: toHex(value) }
|
HookParameter: { HookParameterName: toHex(label), HookParameterValue: value }
|
||||||
})
|
})
|
||||||
}, [])
|
}, [])
|
||||||
const Memos = memos
|
const Memos = memos
|
||||||
? Object.entries(memos).reduce<SetHookData['Memos']>((acc, [_, { format, data, type }]) => {
|
? Object.entries(memos).reduce<SetHookData['Memos']>((acc, [_, { format, data, type }]) => {
|
||||||
return acc?.concat({
|
return acc?.concat({
|
||||||
Memo: { MemoData: toHex(data), MemoFormat: toHex(format), MemoType: toHex(type) }
|
Memo: { MemoData: data, MemoFormat: toHex(format), MemoType: toHex(type) }
|
||||||
})
|
})
|
||||||
}, [])
|
}, [])
|
||||||
: undefined
|
: undefined
|
||||||
|
|||||||
@@ -406,7 +406,7 @@ export const TxUI: FC<UIProps> = ({
|
|||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
css={{ mx: '$2' }}
|
css={{ mx: '$2' }}
|
||||||
placeholder="Value"
|
placeholder="Value (hex-quoted)"
|
||||||
value={value}
|
value={value}
|
||||||
onChange={e => {
|
onChange={e => {
|
||||||
setState({
|
setState({
|
||||||
@@ -469,7 +469,7 @@ export const TxUI: FC<UIProps> = ({
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
placeholder="Data"
|
placeholder="Data (hex-quoted)"
|
||||||
css={{ mx: '$2' }}
|
css={{ mx: '$2' }}
|
||||||
value={memo.data}
|
value={memo.data}
|
||||||
onChange={e => {
|
onChange={e => {
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ export const prepareState = (value: string, transactionType?: string) => {
|
|||||||
|
|
||||||
if (HookParameters && HookParameters instanceof Array) {
|
if (HookParameters && HookParameters instanceof Array) {
|
||||||
tx.hookParameters = HookParameters.reduce<TransactionState["hookParameters"]>((acc, cur, idx) => {
|
tx.hookParameters = HookParameters.reduce<TransactionState["hookParameters"]>((acc, cur, idx) => {
|
||||||
const param = { label: fromHex(cur.HookParameter?.HookParameterName || ""), value: fromHex(cur.HookParameter?.HookParameterValue || "") }
|
const param = { label: fromHex(cur.HookParameter?.HookParameterName || ""), value: cur.HookParameter?.HookParameterValue || "" }
|
||||||
acc[idx] = param;
|
acc[idx] = param;
|
||||||
return acc;
|
return acc;
|
||||||
}, {})
|
}, {})
|
||||||
@@ -223,7 +223,7 @@ export const prepareState = (value: string, transactionType?: string) => {
|
|||||||
|
|
||||||
if (Memos && Memos instanceof Array) {
|
if (Memos && Memos instanceof Array) {
|
||||||
tx.memos = Memos.reduce<TransactionState["memos"]>((acc, cur, idx) => {
|
tx.memos = Memos.reduce<TransactionState["memos"]>((acc, cur, idx) => {
|
||||||
const memo = { data: fromHex(cur.Memo?.MemoData || ""), type: fromHex(cur.Memo?.MemoType || ""), format: fromHex(cur.Memo?.MemoFormat || "") }
|
const memo = { data: cur.Memo?.MemoData || "", type: fromHex(cur.Memo?.MemoType || ""), format: fromHex(cur.Memo?.MemoFormat || "") }
|
||||||
acc[idx] = memo;
|
acc[idx] = memo;
|
||||||
return acc;
|
return acc;
|
||||||
}, {})
|
}, {})
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export const tts = {
|
|||||||
export type TTS = typeof tts
|
export type TTS = typeof tts
|
||||||
|
|
||||||
const calculateHookOn = (arr: (keyof TTS)[]) => {
|
const calculateHookOn = (arr: (keyof TTS)[]) => {
|
||||||
let s = '0x3e3ff5bf'
|
let s = '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff'
|
||||||
arr.forEach(n => {
|
arr.forEach(n => {
|
||||||
let v = BigInt(s)
|
let v = BigInt(s)
|
||||||
v ^= BigInt(1) << BigInt(tts[n])
|
v ^= BigInt(1) << BigInt(tts[n])
|
||||||
|
|||||||
@@ -85,7 +85,8 @@ export const getInvokeOptions = (content?: string) => {
|
|||||||
export function toHex(str: string) {
|
export function toHex(str: string) {
|
||||||
var result = ''
|
var result = ''
|
||||||
for (var i = 0; i < str.length; i++) {
|
for (var i = 0; i < str.length; i++) {
|
||||||
result += str.charCodeAt(i).toString(16)
|
const hex = str.charCodeAt(i).toString(16)
|
||||||
|
result += hex.padStart(2, '0')
|
||||||
}
|
}
|
||||||
return result.toUpperCase()
|
return result.toUpperCase()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user