Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 26 additions & 12 deletions src/components/contract/ContractActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default defineComponent({
name: 'ContractActions',
components: { ViewTransaction },
setup() {
const memo = ref<Record<string, unknown>>({});
const actionData = ref<Record<string, unknown>>({});
const permission = ref<string>('');
const accountStore = useAccountStore();
const actor = ref('');
Expand All @@ -25,31 +25,45 @@ export default defineComponent({
);

async function signAction() {
const actDataObj = actionDataToObject();
await accountStore.sendAction({
name: action.value,
actor: actor.value,
permission: permission.value,
data: memo.value,
data: actDataObj,
});
openTransaction.value = true;
}

function formatMemo() {
for (let key in memo.value) {
function actionDataToObject() {
const obj: {[key: string]: unknown} = {};
for (let key in actionData.value) {
const field = fields.value.find(val => val.name === key);
let value = actionData.value[key];
if (typeof value === 'string' && field.type.endsWith('[]')) {
value = JSON.parse(value);
}
obj[key] = value;
}
return obj;
}

function formatActionData() {
for (let key in actionData.value) {
const field = fields.value.find(val => val.name === key);
if (field.type === 'bool') {
memo.value[key] = memo.value[key] === 'true' ||
memo.value[key] === '1' ||
memo.value[key] === 'True' ||
memo.value[key] === 'T' ||
memo.value[key] === 't';
actionData.value[key] = actionData.value[key] === 'true' ||
actionData.value[key] === '1' ||
actionData.value[key] === 'True' ||
actionData.value[key] === 'T' ||
actionData.value[key] === 't';
}
}
}

watch(actions, () => {
action.value = actions.value[0];
memo.value = {};
actionData.value = {};
});

onMounted(() => {
Expand All @@ -61,14 +75,14 @@ export default defineComponent({
action,
actions,
fields,
memo,
memo: actionData,
signAction,
actor,
permission,
openTransaction,
transactionId,
transactionError,
formatMemo,
formatMemo: formatActionData,
};
},
});
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2680,10 +2680,10 @@
"@wharfkit/token" "^1.1.2"
tslib "^2.1.0"

"@wharfkit/antelope@1.0.10":
version "1.0.10"
resolved "https://registry.yarnpkg.com/@wharfkit/antelope/-/antelope-1.0.10.tgz#5c63d6b67a4b62038575cd86ef47edaa8d1f57dd"
integrity sha512-12m4nD6+ZZl+mwzySuFkeiJCOrbXQT6mqg9amr1l/JtRewRdxeN9QTsEoPjE5MCTXbJc84X51KCT71ysglse0Q==
"@wharfkit/antelope@1.0.13":
version "1.0.13"
resolved "https://registry.yarnpkg.com/@wharfkit/antelope/-/antelope-1.0.13.tgz#216b28da9d9a91ece9db273447f4419aa770657f"
integrity sha512-f4O5O8+6Bd5BHpMUHTmlWQmlhX5xYb4AfzT2NJweyqIPqQOstm+aInF42AtUhSALDa8fvoY80YZoqwM0L8TUyw==
dependencies:
bn.js "^4.11.9"
brorand "^1.1.0"
Expand Down
Loading