Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to send comments #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
15 changes: 11 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Address, beginCell, Cell, fromNano, SendMode, toNano} from "@ton/core";
import {Address, beginCell, Cell, comment, fromNano, SendMode, toNano} from "@ton/core";
import {THEME, TonConnectUI} from '@tonconnect/ui'
import {
AddressInfo,
Expand Down Expand Up @@ -560,7 +560,7 @@ $('#order_approveButton').addEventListener('click', async () => {

// NEW ORDER

type FieldType = 'TON' | 'Jetton' | 'Address' | 'URL' | 'Status';
type FieldType = 'TON' | 'Jetton' | 'Address' | 'URL' | 'Status' | 'String';

interface ValidatedValue {
value?: any;
Expand Down Expand Up @@ -631,6 +631,9 @@ const validateValue = (fieldName: string, value: string, fieldType: FieldType):
}
return makeValue(value);

case 'String':
return makeValue(value);

case 'Status':
if (LOCK_TYPES.indexOf(value) > -1) {
return makeValue(value);
Expand Down Expand Up @@ -722,13 +725,17 @@ const orderTypes: OrderType[] = [
toAddress: {
name: 'Destination Address',
type: 'Address'
},
comment: {
name: 'Comment',
type: 'String'
}
},
makeMessage: async (values) => {
return {
toAddress: values.toAddress,
tonAmount: values.amount,
body: beginCell().endCell()
body: values.comment.length > 0 ? comment(values.comment) : beginCell().endCell()
};
}
},
Expand Down Expand Up @@ -1697,4 +1704,4 @@ const processUrl = async () => {

processUrl();

window.onpopstate = () => processUrl();
window.onpopstate = () => processUrl();